Interpolation on K8s deployment

Viewed 112

How do I pass in a variable inside another string value in k8s deployments.

enter image description here

1 Answers

Variable references are possible using the $(ENV_VAR) format. So, in this example, it would be:

containers:
 - env: 
     - name: DATA_SOURCE_PASS
       valueFrom:
         secretKeyRef:
           name: app-secrets
           key: DB_DOCKER_USER_PASSWORD
     - name: PG_EXPORTER_URL
       value: postgres://postgres:$(DATA_SOURCE_PASS)@localhost:5432/postgres
  • This question has already been answered here, which is where I got this answer from.
  • Kubernetes documentation on variable references, also linked from article above.
Related