I have a kubernetes cluster with vault installed (by a helm chart).
I want to populate secret from vault to a file in a pod (nginx for example) and refresh the secrets every 5 minutes.
I used the following configuration to test it (with appropriate vault policy/backend auth):
namespace.yaml
apiVersion: v1
kind: Namespace
metadata:
name: web
Service_account.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: nginx
namespace: web
secrets:
- name: nginx
nginx-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
namespace: web
labels:
app: nginx
run: nginx
version: vault-injector
spec:
replicas: 1
selector:
matchLabels:
run: nginx
version: vault-injector
template:
metadata:
labels:
app: nginx
run: nginx
version: vault-injector
annotations:
vault.hashicorp.com/agent-inject: "true"
vault.hashicorp.com/role: "nginx"
#vault.hashicorp.com/agent-inject-status: "update"
vault.hashicorp.com/agent-inject-secret-nginx.pass: "infrastructure/nginx/"
spec:
serviceAccountName: nginx
containers:
- name: nginx
image: nginx
ports:
- name: http
containerPort: 80
When i apply this configuration to my kubernetes cluster the deployment is created and my secret are filled into /vault/secret/nginx.pass(as expected).
kubectl exec -it pod/nginx-69955d8744-v9jm2 -n web -- cat /vault/secrets/nginx.pass
Password1: MySecretPassword1
Password2: MySecretPassword2
I tried to update the kv and add a password on nginx kv but my pods doesn't refresh the file on /vault/secrets/nginx.pass. If i restart my secrets are filled
Is it possible to dynamically refresh the kv ? What's the best way to do it ? I want to use vault as a configuration manager and be able to modify kv without restarting pods.