Helm chart passing multiple environment values for single key

10/9/2018

I am new to helm charts and I am trying to pass some environment variables to schema-registry

Values.yaml

replicaCount: 1

image:
  repository: confluentinc/cp-schema-registry
  tag: 5.0.0
  pullPolicy: IfNotPresent
  env:
    - name: "SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS"
      value: "PLAINTEXT://xx.xxx.xx.x:9092,PLAINTEXT://xx.xxx.xx.x:9092,PLAINTEXT://xx.xxx.xx.x:9092"
    - name: "SCHEMA_REGISTRY_LISTENERS"
      value: "http://0.0.0.0:8083"

But these environment variables are not passed to the pod.

I tried passing as part of install command, but it failed because I cannot pass multiple values, Can anyone please let me know how you have passed your multiple environment variables

ubuntu@ip-10-xx-x-xx:~/helm-test$ helm install helm-test-0.1.0.tgz --set SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS=PLAINTEXT://xx.xxx.xx.xx:9092,PLAINTEXT://xx.xxx.xx.xx:9092,PLAINTEXT://xx.xxx.xx.xx:9092,SCHEMA_REGISTRY_LISTENERS=http://0.0.0.0:8083
Error: failed parsing --set data: key "97:9092" has no value (cannot end with ,)

After trying to pass the environment values both inside the values.yaml file and also as install command

replicaCount: 1

image:
  repository: confluentinc/cp-schema-registry
  tag: 5.0.0
  pullPolicy: IfNotPresent
  env:
    - name:
       SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS: "PLAINTEXT://10.xxx.x.xx:9092,PLAINTEXT://10.xxx.x.xx:9092,PLAINTEXT://10.xxx.x.xx.xxx:9092"
       SCHEMA_REGISTRY_LISTENERS: "http://0.0.0.0:8083"


helm install helm-test-0.1.0.tgz --set env.name.SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS="PLAINTEXT://10.xx.x.xx:9092\,PLAINTEXT://10.xx.x.xx:9092\,PLAINTEXT://10.xx.x.xx:9092", --set env.nameSCHEMA_REGISTRY_LISTENERS="http://0.0.0.0:8083"

I escaped the commas since it was throwing an error Error: failed parsing --set data: key "xxx:9092" has no value (cannot end with ,)

I see that my environment values does not show when i try to describe a deployment.

kubectl describe deployment/crusty-aardwolf-helm-test
Name:                   crusty-aardwolf-helm-test
Namespace:              default
CreationTimestamp:      Wed, 10 Oct 2018 14:23:37 +0000
Labels:                 app.kubernetes.io/instance=crusty-aardwolf
                        app.kubernetes.io/managed-by=Tiller
                        app.kubernetes.io/name=helm-test
                        helm.sh/chart=helm-test-0.1.0
Annotations:            deployment.kubernetes.io/revision=1
Selector:               app.kubernetes.io/instance=crusty-aardwolf,app.kubernetes.io/name=helm-test
Replicas:               1 desired | 1 updated | 1 total | 0 available | 1 unavailable
StrategyType:           RollingUpdate
MinReadySeconds:        0
RollingUpdateStrategy:  25% max unavailable, 25% max surge
Pod Template:
  Labels:  app.kubernetes.io/instance=crusty-aardwolf
           app.kubernetes.io/name=helm-test
  Containers:
   helm-test:
    Image:        confluentinc/cp-schema-registry:5.0.0
    Port:         80/TCP
    Host Port:    0/TCP
    Liveness:     http-get http://:http/ delay=0s timeout=1s period=10s #success=1 #failure=3
    Readiness:    http-get http://:http/ delay=0s timeout=1s period=10s #success=1 #failure=3
    Environment:  <none>

Why are my environment values not passed to my container? Can someone please point me in right direction.

-- user_01_02
kubectl
kubernetes
kubernetes-helm

1 Answer

10/9/2018

The values.yaml is more for actual values. You can use go template substitutions if you'd like to but it's less common. (These substitutions get used later in a template)

When you specify --set in for example helm install --set foo=bar foo will be overridden by bar in the values.yaml file. What you may really want is something like this:

...
env:
  name:
    SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS: "PLAINTEXT://xx.xxx.xx.x:9092,PLAINTEXT://xx.xxx.xx.x:9092,PLAINTEXT://xx.xxx.xx.x:9092"
    SCHEMA_REGISTRY_LISTENERS: "http://0.0.0.0:8083"

and then on the helm install command line:

helm install helm-test-0.1.0.tgz --set env.name.SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS="PLAINTEXT://xx.xxx.xx.xx:9092,PLAINTEXT://xx.xxx.xx.xx:9092,PLAINTEXT://xx.xxx.xx.xx:9092" --set env.nameSCHEMA_REGISTRY_LISTENERS="http://0.0.0.0:8083"

More information on how to set the values here.

-- Rico
Source: StackOverflow