Chandra Sekar
Chandra Sekar

Reputation: 763

Expose mulitple containerPort via values.yaml

Is there any way to pass array of ports in values.yaml file. I want to have multiple ContainerPorts to be set. I tried with --set "test.containerPort={8080,10102,19905} and got error message as invalid type for io.k8s.apimachinery.pkg.util.intstr.IntOrString: got "array", expected "string".

Any example/suggestions will be really helpful.

Upvotes: 1

Views: 2812

Answers (1)

Rafał Leszko
Rafał Leszko

Reputation: 5541

Helm uses the Go templating mechanism, so it actually takes your parameters from values.yaml and puts them into template/* files.

In other words, the way how you set multiple containers ports depends on the Helm Chart you use.

For example, if had a file template/my-statefulset.yaml

apiVersion: apps/v1
kind: StatefulSet
...
spec:
  template:
    spec:
      containers:
        ports:
{{ toYaml .Values.ports| indent 10 }}
...

Then, you could use the following values.yaml to set multiple container ports.

ports:
  - name: my first port
    containerPort: 5678
  - name: my second port
    containerPort: 5679

Upvotes: 3

Related Questions