Created
August 9, 2019 21:15
-
-
Save TsuyoshiUshio/f1fa79251be75f29fe42a92d035d4190 to your computer and use it in GitHub Desktop.
Sample Yaml for Vault Agent with Consul Template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| apiVersion: v1 | |
| kind: Pod | |
| metadata: | |
| name: vault-agent-example | |
| spec: | |
| serviceAccountName: vault-auth | |
| restartPolicy: Never | |
| volumes: | |
| - name: vault-token | |
| emptyDir: | |
| medium: Memory | |
| - name: config | |
| configMap: | |
| name: example-vault-agent-config | |
| items: | |
| - key: vault-agent-config.hcl | |
| path: vault-agent-config.hcl | |
| - key: consul-template-config.hcl | |
| path: consul-template-config.hcl | |
| - name: shared-data | |
| emptyDir: {} | |
| initContainers: | |
| # Vault container | |
| - name: vault-agent-auth | |
| image: vault | |
| volumeMounts: | |
| - name: config | |
| mountPath: /etc/vault | |
| - name: vault-token | |
| mountPath: /home/vault | |
| # This assumes Vault running on local host and K8s running in Minikube using VirtualBox | |
| env: | |
| - name: VAULT_ADDR | |
| value: http://vault.default.svc.cluster.local:8200 | |
| # Run the Vault agent | |
| args: | |
| [ | |
| "agent", | |
| "-config=/etc/vault/vault-agent-config.hcl", | |
| "-log-level=debug", | |
| ] | |
| containers: | |
| # Consul Template container | |
| - name: consul-template | |
| image: hashicorp/consul-template:alpine | |
| imagePullPolicy: Always | |
| volumeMounts: | |
| - name: vault-token | |
| mountPath: /home/vault | |
| - name: config | |
| mountPath: /etc/consul-template | |
| - name: shared-data | |
| mountPath: /etc/secrets | |
| env: | |
| - name: HOME | |
| value: /home/vault | |
| - name: VAULT_ADDR | |
| value: http://vault.default.svc.cluster.local:8200 | |
| # Consul-Template looks in $HOME/.vault-token, $VAULT_TOKEN, or -vault-token (via CLI) | |
| args: | |
| [ | |
| "-config=/etc/consul-template/consul-template-config.hcl", | |
| #"-log-level=debug", | |
| ] | |
| # Nginx container | |
| - name: nginx-container | |
| image: nginx | |
| ports: | |
| - containerPort: 80 | |
| volumeMounts: | |
| - name: shared-data | |
| mountPath: /usr/share/nginx/html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment