How to use imagePullSecrets: [] in Helm 3

65k Views Asked by At

Helm 3 imagePullSecrets: [] secrete gives an error.

Error: unable to build Kubernetes objects from release manifest: error validating "": error validating data: ValidationError(Deployment.spec.template.spec.imagePullSecrets[0]): invalid type for io.k8s.api.core.v1.LocalObjectReference: got "string", expected "map"

3

There are 3 best solutions below

3
On

I use this setup and works fine.

In deployment.yaml

    spec:
    {{- with .Values.imagePullSecrets }}
      imagePullSecrets:
        {{- toYaml . | nindent 8 }}
    {{- end }}
      containers:

In values.yaml

imagePullSecrets:
  - name: regcred

And create secret regcred manually using

kubectl create secret docker-registry regcred --docker-server=<your-registry-server> --docker-username=<your-name> --docker-password=<your-pword> --docker-email=<your-email>

You can find detailed documentation here

0
On

How to create ImagePullSecret:

https://helm.sh/docs/howto/charts_tips_and_tricks/#creating-image-pull-secrets

Add to deployment:

spec:
    imagePullSecrets:
    - name: myregistrykey
0
On

Specifying the imagePullSecret in your values.yaml as:

imagePullSecrets: ["yourSecret"]

will result in the error that you got. The key info in the error is:

got "string", expected "map"

The manifest requires a 'map' object for `imagePullSecret'. Which should look like this:

imagePullSecrets: [{ name: yourSecret }]

Executing:

helm install --dry-run .\mychart

also helps to validate the change:

COMPUTED VALUES:
...
imagePullSecrets:
- name: yourSecret 
...