How to pass values into Helm app

Photo by Loik Marras on Unsplash

How to pass values into Helm app

Different methods to pass values into Helm:

  1. Directly modify values.yaml file in Helm chart (not recommended)
  2. Instead of editing values.yaml file directly, we can pass values into Helm via CLI. For example to change replicaCount value we can use:
    helm install --set [values_property_name]=[number] [release_name] [chart_name]
    helm install --set replicaCount=2 app helloworld
    
  3. You can define your own values.yaml file to define custom variables:
    helm install -f [custom_values_file] [release_name] [chart_name]
    helm install -f myvalues.yaml app helloword/
    
  4. Use key-pair values to pass data into Helm. To use these values we need to iterate through them. For example:
    // env-values.yaml
    // Define custom config key-pair values yaml file map:
    vars:
    - name: "USERNAME"
     value: "john"
    - name: "PASSWORD"
     value: "P@ssw0rd"
    
  5. After defining separate file for environment variables, edit your deployment.yaml file to iterate through the values:
    ...
    env:
    {{- range .Values.vars }}
    - name: {{ .name }}
     value: {{ .value }}
    {{- end }}
    ...
    

Useful Helm commands

  1. To list Helm releases use:
    helm list
    
  2. To delete Helm release use:
    helm delete [release_name]
    
  3. Use Helm template command to see values that will be used during chart installation:
    helm template -f [env_values_file_name] [chart_name]
    helm template -f env-values.yaml helloworld/