Nati Koli
Nati Koli

Reputation: 56

Error iterating over a list of values in helm

I am trying to iterate over a list in Helm3, in order to create several namespaces in one template file.

values.yaml

namespace:
  - dev
  - vv

templates/namespaces.yaml

{{- range .Values.namespace }}
---
apiVersion: v1
kind: Namespace
metadata:
  name: {{ . | quote }}
{{- end }}

However when I try to helm install . -f values.yaml I get the following error:

Error: unable to build kubernetes objects from release manifest: error validating "": error validating data: ValidationError(Secret.metadata.namespace): invalid type for io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta.namespace: got "array", expected "string"

Any ideas what i'm doing wrong?

Upvotes: 3

Views: 2486

Answers (1)

Mafor
Mafor

Reputation: 10681

Actually the error does not relate to the templates/namespaces.yaml but to some other template (secret). Probably the namespace from the values.yaml overrides a value with the same name from the default values.yaml. Try renaming it, e.g. namespaces.

Upvotes: 4

Related Questions