Managing Helm Values Files

In complex installations it may be necessary or helpful to use more than one Helm values file. The helm install and helm upgrade commands can accept multiple values files, with values in files listed later taking precedence. Layering Helm values files in this way can be used to reduce duplication.

In the following example:

  • componentA is deployed in the matrixx1 namespace.
  • componentB is deployed in the matrixx2 namespace.
  • Both components share some common configuration.

A non-layered approach duplicates the shared configuration in near-identical values files:

helm install ag1 matrixx/matrixx -n matrixx1 -f matrixx1.yaml --version matrixx_version
helm install ag1 matrixx/matrixx -n matrixx2 -f matrixx2.yaml --version matrixx_version

The matrixx1.yaml file enables componentA and disables componentB:

componentA:
  enabled: true
 
componentB:
  enabled: false
  
global:
  image:
    registry:
      name: a.j.m0012242008.com/mtx-docker-eng-snapshot
      password: AP4i7fj8EHTm69s72a9sYDvqb6h
      username: build

The matrixx2.yaml file enables componentB and disables componentA:

componentA:
  enabled: false
 
componentB:
  enabled: true
  
global:
  image:
    registry:
      name: a.j.m0012242008.com/mtx-docker-eng-snapshot
      password: AP4i7fj8EHTm69s72a9sYDvqb6h
      username: build

A layered approach extracts the shared configuration into a separate Helm values file, here base.yaml:

componentA:
  enabled: false
 
componentB:
  enabled: false
  
global:
  image:
    registry:
      name: a.j.m0012242008.com/mtx-docker-eng-snapshot
      password: AP4i7fj8EHTm69s72a9sYDvqb6h
      username: build

The componentA.yaml file only enables componentA:

componentA:
  enabled: true

and the componentB.yaml file only enables componentB:

componentB:
  enabled: true

The following helm install commands apply the layered files:

helm install ag1 matrixx/matrixx -n matrixx1 -f base.yaml -f componentA.yaml --version matrixx_version
helm install ag1 matrixx/matrixx -n matrixx2 -f base.yaml -f componentB.yaml --version matrixx_version

In cases such as this where the additional configuration is sufficiently simple, an alternative approach is to use the -–set flag:

helm install ag1 matrixx/matrixx -n matrixx1 -f base.yaml --set componentA.enabled=true --version matrixx_version
helm install ag1 matrixx/matrixx -n matrixx2 -f base.yaml --set componentB.enabled=true --version matrixx_version