I am trying to update a helm-deployed deployment so that it uses a secret stored as a k8s secret resource. This must be set as the STORAGE_PASSWORD environment variable in my pod.
In my case, the secret is in secrets/redis and the data item is redis-password:
$ kubectl get secret/redis -oyaml apiVersion: v1 data: redis-password: XXXXXXXXXXXXXXXX= kind: Secret metadata: name: redis type: Opaque
I have tried:
$ kubectl set env --from secret/redis deployment/gateway --keys=redis-password Warning: key redis-password transferred to REDIS_PASSWORD deployment.apps/gateway env updated
When I look in my updated deployment manifest, I see the variable has been added but (as suggested) the variable has been set to REDIS_PASSWORD:
- name: REDIS_PASSWORD
valueFrom:
secretKeyRef:
key: redis-password
name: redis
I have also tried kubectl patch with a replace operation, but I can't get the syntax correct to have the secret inserted.
How do I change the name of the environment variable to STORAGE_PASSWORD?
kubectl setorkubectl editon something Helm is managing, since the results will be somewhat unpredictable if youhelm upgradethe chart. Can you make this change in thetemplates/deployment.yamlfile instead, maybe gated on some specific{{ if .Values... }}setting?