Referring to namespace using environment variable Referring to namespace using environment variable kubernetes kubernetes

Referring to namespace using environment variable


I guess this is in a helm chart for an app that you're deploying with jenkins-x. Helm has a Release.Namespace value that you can access. So in the deployment.yaml you could use {{ .Release.Namespace }} Although jx-staging is also the name of the release so {{ .Release.Name}} that could equally apply here. I would expect this to look like:

      valueFrom:        secretKeyRef:          name: {{ .Release.Name }}-{{ .Values.rabbitmq.name }}          key: rabbitmq-password

Where {{ .Values.rabbitmq.name }} is equal to rabbitmq or whatever you call rabbitmq in your requirements.yaml. (Here's an example chart doing it this way for postgres, it also uses rabbit but accesses the rabbit password differently.)

If you have the secret loading correctly but still get password problems then make sure you're setting an explicit password value as otherwise you could be hitting https://github.com/helm/charts/issues/5167

The use of {{ .Release.Name }} won't work inside of the values.yaml but I'm not sure if you need it to if you can do it in the deployment.yaml.

(If you really do need access to a function from the values.yaml then you need to have an entry for the string value in the values.yaml and then pass it through the tpl function within the template.)