Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distribution chart is unable to use Pod fields as values for environment variables with extraEnvironmentVariables #1814

Open
mikeycmccarthy opened this issue Sep 8, 2023 · 0 comments

Comments

@mikeycmccarthy
Copy link

Is this a request for help?:

YES


Is this a BUG REPORT or FEATURE REQUEST? (choose one):

FEATURE REQUEST

Version of Helm and Kubernetes:

Kubernetes: 1.21.2
Helm: 3.10.3

Which chart:

Distribution

Which product license (Enterprise/Pro/oss):

Entreprise+

JFrog support reference (if already raised with support team):

N/A

What happened:

I tried to set an environment variable using the extraEnvironmentVariables property of the Distribution chart. This was not a simple value but a 'valueFrom' with a fieldRef. Specifically this was to support Dynatrace version detection strategies (https://www.dynatrace.com/support/help/platform-modules/cloud-automation/release-monitoring/version-detection-strategies) but really this is for any environment variable that is not a simple value based one.

What you expected to happen:

I expected the environment variable to be set in the resulting manifest for the stateful set, but it wasn't, and instead Helm through an error.

The explanation is quite simple - the way the Distribution chart works is that the extraEnvironmentVariables property always expects a key and a value, and when it gets templated out it is very specific about this, see https://github.com/jfrog/charts/blob/master/stable/distribution/templates/distribution-statefulset.yaml#L339-L342.

        {{- range .Values.distribution.extraEnvironmentVariables }}
        - name: {{ .name }}
          value: '{{ tpl .value $ }}'
        {{- end }}

This is different to the way this works within the Artifactory chart:

https://github.com/jfrog/charts/blob/master/stable/artifactory/templates/artifactory-statefulset.yaml#L442C1-L444C11

{{- with .Values.artifactory.extraEnvironmentVariables }}
{{ tpl (toYaml .) $ | indent 8 }}
{{- end }}

The Artifactory chart supports all types of environment variables, so you can set them in your values file exactly as they would turn up in the manifest.

How to reproduce it (as minimally and precisely as possible):

Set the extraEnvironmentVariables within the Distribution Helm chart to use a pod field (https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/#use-pod-fields-as-values-for-environment-variables)

Anything else we need to know:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant