{"id":2514,"date":"2022-02-24T21:27:04","date_gmt":"2022-02-24T12:27:04","guid":{"rendered":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/?p=2514"},"modified":"2022-02-24T21:27:04","modified_gmt":"2022-02-24T12:27:04","slug":"yassan-argocd-with-aws-secrets-manager","status":"publish","type":"post","link":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2022\/02\/24\/yassan-argocd-with-aws-secrets-manager\/","title":{"rendered":"ArgoCD Vault Plugin\u3068AWS Secrets Manager\u3092\u5229\u7528\u3057\u3066Kubernetes\u306e\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u60c5\u5831\u3092\u7ba1\u7406\u3059\u308b"},"content":{"rendered":"

\u5468\u56f2\u3067\u30b3\u30ed\u30ca\u30a6\u30a4\u30eb\u30b9\u306b\u611f\u67d3\u3057\u305f\u65b9\u304c\u5897\u3048\u3066\u304d\u3066\u304a\u308a\u3001\u307e\u3059\u307e\u3059\u5bb6\u306b\u5f15\u304d\u3053\u3082\u3063\u3066\u304a\u308a\u307e\u3059\u3002\u3084\u3063\u3055\u3093\u3067\u3054\u3056\u3044\u307e\u3059\u3002<\/p>\n

ArgoCD Vault Plugin\u3068AWS Secrets Manager\u3092\u5229\u7528\u3057\u3066Kubernetes\u306e\u79d8\u5bc6\u60c5\u5831\u3092\u7ba1\u7406\u3057\u3066\u307f\u307e\u3057\u305f\u306e\u3067\u3054\u7d39\u4ecb\u3044\u305f\u3057\u307e\u3059\u3002<\/p>\n

ArgoCD Vault Plugin\u3068\u306f<\/h2>\n

ArgoCD Vault Plugin<\/code> \u306fKubernetes\u306e\u30de\u30cb\u30d5\u30a7\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u306b\u79d8\u5bc6\u60c5\u5831\u3092\u6ce8\u5165\u3059\u308b\u305f\u3081\u306eArgo CD\u30d7\u30e9\u30b0\u30a4\u30f3\u3067\u3059\u3002\u69d8\u3005\u306a\u79d8\u5bc6\u60c5\u5831\u7ba1\u7406\u30c4\u30fc\u30eb\u306b\u5bfe\u5fdc\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n

\u79d8\u5bc6\u60c5\u5831\u7ba1\u7406\u30c4\u30fc\u30eb\u306b\u306f\u3001HashiCorp Vault\u3001AWS Secrets Manager\u306a\u3069\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n

\u306a\u305c\u79d8\u5bc6\u60c5\u5831\u7ba1\u7406\u30c4\u30fc\u30eb\u304c\u5fc5\u8981\u304b<\/h2>\n

Kubernetes\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u3068\u3044\u3046\u30de\u30cb\u30d5\u30a7\u30b9\u30c8\u304c\u3042\u308a\u307e\u3057\u3066\u3001\u79d8\u5bc6\u60c5\u5831\u306f\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u3067\u7ba1\u7406\u3059\u308b\u3053\u3068\u306b\u3088\u308aKubectl\u3067\u53c2\u7167\u3057\u305f\u3068\u3057\u3066\u3082\u79d8\u533f\u6027\u304c\u7dad\u6301\u3055\u308c\u307e\u3059\u3002<\/p>\n

\u3088\u304f\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u306b\u3064\u3044\u3066\u8a00\u308f\u308c\u308b\u3053\u3068\u3068\u3057\u307e\u3057\u3066\u3001\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u3092\u7ba1\u7406\u3059\u308byaml\u30d5\u30a1\u30a4\u30eb\u306e\u30a8\u30f3\u30b3\u30fc\u30c9\u306f base64<\/code> \u3067\u3042\u308b\u305f\u3081\u3001\u7c21\u5358\u306b\u30c7\u30b3\u30fc\u30c9\u51fa\u6765\u3066\u3057\u307e\u3046\u3068\u3044\u3046\u306e\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n

\u4e0a\u8a18\u306e\u7406\u7531\u304b\u3089\u3001\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u306e base64<\/code> \u30a8\u30f3\u30b3\u30fc\u30c9\u306b\u983c\u3089\u305a\u3001\u4ed6\u306e\u79d8\u5bc6\u60c5\u5831\u7ba1\u7406\u30c4\u30fc\u30eb\u3092\u4f7f\u3046\u65b9\u6cd5\u304c\u591a\u304f\u63d0\u6848\u3055\u308c\u3066\u3044\u307e\u3059\u3002Argo CD Vault Plugin<\/code> \u4ee5\u5916\u306b\u3082 Bitnami Sealed Secrets<\/code> \u3084 GoDaddy Kubernetes External Secrets<\/code> \u306a\u3069\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n

ArgoCD Vault Plugin\u306b\u7740\u76ee\u3057\u305f\u70b9\u3068\u3057\u307e\u3057\u3066\u306f\u3001\u30d7\u30e9\u30b0\u30a4\u30f3\u306b\u3088\u3063\u3066\u5c0e\u5165\u51fa\u6765\u308b\u305f\u3081\u3001\u65b0\u305f\u306b\u30dd\u30c3\u30c9\u3092\u8ffd\u52a0\u3059\u308b\u5fc5\u8981\u304c\u306a\u3044\u3068\u3044\u3046\u70b9\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n

ArgoCD Valut Plugin\u306e\u5c0e\u5165<\/h2>\n

\u305d\u308c\u3067\u306f\u3001\u5c0e\u5165\u65b9\u6cd5\u306b\u3064\u3044\u3066\u3054\u7d39\u4ecb\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n

1. ArgoCD\u306e\u30ab\u30b9\u30bf\u30de\u30a4\u30ba<\/h3>\n

\u4eca\u56de\u306fArgoCD\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u63d0\u4f9b\u3055\u308c\u3066\u3044\u308b\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u7528\u306eyaml\u30d5\u30a1\u30a4\u30eb\u3092\u30d9\u30fc\u30b9\u306bPlugin\u306e\u8a2d\u5b9a\u3092\u8a18\u8f09\u3057\u305fyaml\u30d5\u30a1\u30a4\u30eb\u3092\u7528\u610f\u3057\u307e\u3057\u305f\u3002<\/p>\n

yaml\u30d5\u30a1\u30a4\u30eb\u306fGitHub<\/a>\u3067\u516c\u958b\u3057\u3066\u304a\u308a\u307e\u3059\u306e\u3067\u3001\u3088\u308d\u3057\u3051\u308c\u3070\u3054\u53c2\u7167\u4e0b\u3055\u3044\u3002
\n\u5909\u66f4\u3057\u305fyaml\u30d5\u30a1\u30a4\u30eb\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n

1-1. argocd-repo-server\u306edeployment<\/h4>\n

argocd-repo-server<\/code> \u30b3\u30f3\u30c6\u30ca\u306e volumeMounts<\/code> \u306b\u4e0b\u8a18\u3092\u8ffd\u8a18\u3057\u307e\u3057\u305f\u3002<\/p>\n

        - mountPath: \/usr\/local\/bin\/argocd-vault-plugin\n          name: custom-tools\n          subPath: argocd-vault-plugin<\/code><\/pre>\n

volumes<\/code> \u306e custom-tools<\/code> \u306b\u4e0b\u8a18\u3092\u8ffd\u8a18\u3057\u307e\u3057\u305f\u3002<\/p>\n

      - emptyDir: {}\n        name: custom-tools<\/code><\/pre>\n

initContainers<\/code> \u306b\u4e0b\u8a18\u3092\u8ffd\u8a18\u3057\u3066\u3001ArgoCD Vault Plugin\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n

      initContainers:\n      - name: download-tools\n        image: alpine:3.8\n        command: [ sh, -c ]\n        args:\n          - >-\n            wget -O argocd-vault-plugin\n            https:\/\/github.com\/IBM\/argocd-vault-plugin\/releases\/download\/v1.1.1\/argocd-vault-plugin_1.1.1_linux_amd64 &&\n            chmod +x argocd-vault-plugin &&\n            mv argocd-vault-plugin \/custom-tools\/\n        volumeMounts:\n          - mountPath: \/custom-tools\n            name: custom-tools<\/code><\/pre>\n

\u305d\u3057\u3066\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306b\u74b0\u5883\u5909\u6570\u3092\u6307\u5b9a\u3057\u3001\u79d8\u5bc6\u7ba1\u7406\u30c4\u30fc\u30eb\u306b AWS Secrets Manager<\/code> \u3092\u6307\u5b9a\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n

        - name: AVP_TYPE\n          value: awssecretsmanager\n        - name: AWS_REGION\n          value: ap-northeast-1<\/code><\/pre>\n

1-2. arcocd-cm\u306econfigmap<\/h4>\n

ArgoCD\u3067\u5229\u7528\u53ef\u80fd\u306b\u3055\u305b\u308b\u3088\u3046\u306bconfigmap\u306b\u4e0b\u8a18\u306e\u3088\u3046\u306b\u8ffd\u8a18\u3057\u307e\u3057\u305f\u3002<\/p>\n

data:\n  configManagementPlugins: |-\n    - name: argocd-vault-plugin\n      generate:\n        command: ["argocd-vault-plugin"]\n        args: ["generate", ".\/"]<\/code><\/pre>\n

1-3. yaml\u30d5\u30a1\u30a4\u30eb\u306e\u9069\u7528<\/h4>\n

\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u4f8b\u306a\u3069\u306b\u3088\u3063\u3066\u3001\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3057\u305fArgoCD\u3092\u30c7\u30d7\u30ed\u30a4\u3057\u307e\u3059\u3002<\/p>\n

kubectl create namespace argocd\nkubectl apply -n argocd -f install.yaml<\/code><\/pre>\n

2. ArgoCD Vault Plugin\u304cAWS Secrets Manager\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u305f\u3081\u306eSecrets\u60c5\u5831\u3092\u4f5c\u6210<\/h3>\n

ArgoCD\u304cAWS Secrets Manager\u306e\u5024\u3092\u53c2\u7167\u3067\u304d\u308b\u3088\u3046\u306bIAM\u30dd\u30ea\u30b7\u30fc\u3092\u4ed8\u4e0e\u3057\u305f\u8a8d\u8a3c\u60c5\u5831\u3092\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u3068\u3057\u3066\u767b\u9332\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n

2-1. \u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u306e\u4f5c\u6210<\/h4>\n

\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u306e\u4f8b\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002\u30d5\u30a1\u30a4\u30eb\u540d\u306f secret-avp-credentials.yaml<\/code> \u3068\u3057\u307e\u3057\u305f\u3002<\/p>\n

kind: Secret\napiVersion: v1\nmetadata:\n  name: argocd-vault-plugin-credentials\n  namespace: argocd\ntype: Opaque\nstringData:\n  AWS_ACCESS_KEY_ID: ***\n  AWS_SECRET_ACCESS_KEY: ***<\/code><\/pre>\n

2-2. \u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u306e\u9069\u7528<\/h4>\n

\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30b3\u30de\u30f3\u30c9\u4f8b\u306b\u3088\u3063\u3066\u3001\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u3092\u9069\u7528\u3057\u307e\u3059\u3002<\/p>\n

kubectl apply -f secret-avp-credentials.yaml<\/code><\/pre>\n

3. AWS Secrets Manager\u306b\u79d8\u5bc6\u60c5\u5831\u3092\u767b\u9332\u3059\u308b<\/h3>\n

AWS Secrets Manager\u306b\u79d8\u5bc6\u60c5\u5831\u3092\u767b\u9332\u3057\u307e\u3059\u3002\u4eca\u56de\u306f\u9805\u76ee\u540d\u3092 secret_test<\/code> \u3001\u5024\u3092 hoge<\/code> \u3068\u3057\u307e\u3057\u305f\u3002<\/p>\n

\"\"<\/a><\/p>\n

4. Kubernetes\u306e\u30de\u30cb\u30d5\u30a7\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u66f4\u65b0\u3057AWS Secrets Manager\u306e\u79d8\u5bc6\u60c5\u5831\u3092\u53c2\u7167\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b<\/h3>\n

Kubernetes\u306e\u30de\u30cb\u30d5\u30a7\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u3067\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b data<\/code> \u306e\u9805\u76ee\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067\u3001AWS Secrets Manager\u306e\u5024\u3092\u53c2\u7167\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u307e\u3059\u3002 <><\/code> \u3067\u56f2\u307e\u308c\u305f\u7b87\u6240\u304c\u8a72\u5f53\u3057\u307e\u3059\u3002<\/p>\n

apiVersion: v1\nkind: Secret\nmetadata:\n  name: avp-test\n  annotations:\n    avp.kubernetes.io\/path: "argocd_test"\ndata:\n  MY_SECRET: <secret_test | base64encode><\/code><\/pre>\n

5. ArgoCD\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u8a2d\u5b9a\u3067ArgoCD Vault Plugin\u3092\u6307\u5b9a\u3059\u308b<\/h3>\n

ArgoCD\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u8a2d\u5b9a\u3067ArgoCD Vault Plugin\u3092\u5229\u7528\u3059\u308b\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002\u8a2d\u5b9a\u65b9\u6cd5\u306f\u7c21\u5358\u3067\u3001\u4ee5\u4e0b\u753b\u50cf\u306e\u3088\u3046\u306b Plugin<\/code> \u306e\u9805\u76ee\u3067 argocd-vault-plugin<\/code> \u3092\u6307\u5b9a\u3059\u308b\u3060\u3051\u3067\u3059\u3002<\/p>\n

\"\"<\/a><\/p>\n

6. ArgoCD\u306b\u3088\u308b\u30c7\u30d7\u30ed\u30a4\u7d50\u679c\u3092\u78ba\u8a8d\u3059\u308b<\/h3>\n

\u9805\u756a5\u3067\u8a2d\u5b9a\u3057\u305f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30c7\u30d7\u30ed\u30a4\u304c\u6210\u529f\u3057\u305f\u5f8c\u306b\u3001Secret\u60c5\u5831\u3092\u78ba\u8a8d\u3057\u3066\u79d8\u5bc6\u60c5\u5831\u304c\u6ce8\u5165\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n

\u307e\u305a\u306f\u3001Secret\u60c5\u5831\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3053\u3068\u3067\u3001base64\u3067\u30a8\u30f3\u30b3\u30fc\u30c9\u3055\u308c\u305fSecret\u60c5\u5831\u3092\u53d6\u5f97\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n

## \u5b9f\u884c\u30b3\u30de\u30f3\u30c9\n$ kubectl get secret avp-test -n argocd-example-app -o jsonpath='{.data}'\n\n## \u5b9f\u884c\u7d50\u679c\n{"MY_SECRET":"aG9nZQ=="}<\/code><\/pre>\n

\u6b21\u306b\u3001\u30a8\u30f3\u30b3\u30fc\u30c9\u3055\u308c\u305fSecret\u60c5\u5831\u3092\u30c7\u30b3\u30fc\u30c9\u3057\u3066\u78ba\u8a8d\u3057\u307e\u3059\u3002\u6b63\u3057\u3044\u5024 hoge<\/code> \u304c\u53d6\u5f97\u3067\u304d\u79d8\u5bc6\u60c5\u5831\u304c\u6b63\u3057\u304f\u6ce8\u5165\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n

## \u5b9f\u884c\u30b3\u30de\u30f3\u30c9\necho 'aG9nZQ==' | base64 --decode\n\n## \u5b9f\u884c\u7d50\u679c\nhoge<\/code><\/pre>\n

\u307e\u3068\u3081<\/h2>\n

ArgoCD Vault Plugin\u3092\u5229\u7528\u3059\u308b\u3053\u3068\u3067\u4ee5\u4e0b\u306e\u3053\u3068\u304c\u5b9f\u73fe\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n