helm icon indicating copy to clipboard operation
helm copied to clipboard

multiple deployments

Open rhaps107 opened this issue 8 years ago • 6 comments

Hi, i need to create multiple deployments in cycle. But it doesn't work, because yaml structure of deployment doesn't accept array of deployments.

Is there any way to create multiple deployments without creating multiple files and copy/paste data?

rhaps107 avatar Apr 26 '18 08:04 rhaps107

You can put multiple YAML documents in one file by separating them with --- on its own line. See for example here: https://github.com/sapcc/helm-charts/blob/master/openstack/limes/templates/collect-deployment.yaml - This loops over a map inside .Values to create multiple Deployments. The second-to-last line is --- which separates the individual Deployments rendered by each loop iteration.

majewsky avatar Apr 26 '18 12:04 majewsky

Hi, can I get a copy of your values.yaml. I would like to have a look at .Values.limes.clusters

himmakam avatar Apr 17 '20 10:04 himmakam

I have something like this in values.yaml replicaCount: 1 maasappname: consumer maasappaliasname: message-consumer instance_names: a: 1 b: 2 And I have deploymentconfig like below - {{ range $key, $value := .Values.instance_names }} kind: "DeploymentConfig" apiVersion: "apps.openshift.io/v1" metadata: name: "maas-{{$key}}" labels: apptype: batch spec: template: metadata: labels: app: "{{ .Values.maasappname }}"

When I run helm install. I get this error - Error: template: maas360/charts/consumer/templates/dc-collect.yaml:12:24: executing "maas360/charts/consumer/templates/dc-collect.yaml" at <.Values.maasappname>: can't evaluate field Values in type interface {} Could you pls help

himmakam avatar Apr 17 '20 11:04 himmakam

@himmakam when iterating data by range, the context is switched to particular element from .Values.instance_names, so actually in range you are trying to access .Values.instance_names.$key.Values.maasappname.

Try to set .Values.maasappname to variable before range: {{ $appName := .Values.maasappname }}

Then use variable in range: app: "{{ $appName }}"

i have a post on my website about GO templates syntax, maybe it also helps https://golangforall.com/en/post/templates.html

antelman107 avatar Apr 17 '20 12:04 antelman107

Inside the range, . refers to the loop variable, i.e. $value. The error is that $value does not have a Values key. To access the global .Values, you can write $.Values.

majewsky avatar Apr 17 '20 12:04 majewsky

ok. thanks a lot.

himmakam avatar Apr 20 '20 12:04 himmakam