Can I add arbitrary config to a pod spec deployed with a helm chart without modifying the helm chart?

6/10/2019

Im using this helm chart to deploy: https://github.com/helm/charts/tree/master/stable/atlantis

It deploys this stateful set: https://github.com/helm/charts/blob/master/stable/atlantis/templates/statefulset.yaml

Is there a way I can add arbitrary config values to a pod spec that was deployed with a helm chart without having to modify the chart? For example I want to add an env: var that gets its value from a secret to the pod spec of the stateful set this chart deploys

Can I create my own helm chart that references this helm chart and add to the config of the pod spec? again without modifying the original chart?

EDIT: what Im talking about is adding an env var like this:

env:
- name: GET_THIS_VAR_IN_ATLANTIS
  valueFrom:
    secretKeyRef:
      name: my-secret
      key: abc

Maybe I can create another chart as a parent of this chart and override the entire env: block?

-- red888
google-cloud-platform
google-kubernetes-engine
kubernetes
kubernetes-helm

1 Answer

6/10/2019

Is there a way I can add arbitrary config values to a pod spec that was deployed with a helm chart without having to modify the chart?

You can only make changes that the chart itself supports.

If you look at the StatefulSet definition you linked to, there are a lot of {{ if .Values.foo }} knobs there. This is an fairly customizable chart and you probably can change most things. As a chart author, you'd have to explicitly write all of these conditionals and macro expansions in.

For example I want to add an env: var that gets its value from a secret to the pod spec of the stateful set this chart deploys

This very specific chart contains a block

{{- range $key, $value := .Values.environment }}
- name: {{ $key }}
  value: {{ $value | quote }}
{{- end }}

so you could write a custom Helm YAML values file and add in

environment:
  arbitraryKey: "any fixed value you want"

and then use the helm install -f option to supply that option when you install the chart.

This chart does not support injecting environment values from secrets, beyond a half-dozen specific values it supports by default (e.g., GitHub tokens).

As I say, this isn't generic at all: this is very specific to what this specific chart supports in its template expansions.

-- David Maze
Source: StackOverflow