Helm - overwrite specific values from values.yaml

9/18/2019

I'm using Helm and for nginx-ingress I need to add some annotations.

Inside the chart's values.yaml file, the podAnnotations is empty ({}).

The question I have is: what is the right way to add these annotations?

The annotations are a child of controller which is the root element of the values.yaml

controller:
  ...
  podAnnotations:
    ...

Now, I get the feeling that I have to copy the whole values.yaml file into my custom-values.yaml in which I added the annotations.

gt; heml install -f .
/custom-values.yaml stable/nginx-ingress

But if I copy the whole values file I get the feeling that I can run into trouble if stable/nginx-ingress changes values inside values.yaml over time

-- Jeanluca Scaljeri
kubernetes-helm

1 Answer

9/18/2019

You do not have to copy all values as you can use your own and override only the values you need

The values.yaml file is also important to templates. This file contains the default values for a chart. These values may be overridden by users during helm install or helm upgrade

See https://helm.sh/docs/chart_template_guide/

Thus just add the annotations to custom-values.yaml - plus other default values you want to change - and then run

helm install -f ./custom-values.yaml stable/nginx-ingress

Here an example of my custom-values.yaml

controller:
  service:
    annotations: 
       field.cattle.io/projectId: c-xxxxx:p-xxxxx

and the important part of the result:

...
# Source: nginx-ingress/templates/controller-service.yaml

apiVersion: v1
kind: Service
metadata:
  annotations:
    field.cattle.io/projectId: "c-xxxxx:p-xxxxx"
  labels:
    app: nginx-ingress
    chart: nginx-ingress-1.20.0
    component: "controller"
    heritage: Tiller
    release: release-name
  name: release-name-nginx-ingress-controller
...
-- papanito
Source: StackOverflow