Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use imagePullSecrets: [] in Helm 3

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"

like image 799
Rajesh Narayanan Avatar asked Jul 14 '20 18:07

Rajesh Narayanan


People also ask

What is _helpers TPL in Helm?

tpl? Helm allows for the use of Go templating in resource files for Kubernetes. A file named _helpers.tpl is usually used to define Go template helpers with this syntax: {{- define "yourFnName" -}} {{- printf "%s-%s" .Values.name .Values.version | trunc 63 -}} {{- end -}}


Video Answer


2 Answers

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

like image 113
Tek Nath Avatar answered Oct 11 '22 00:10

Tek Nath


How to create ImagePullSecret:

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

Add to deployment:

spec:
    imagePullSecrets:
    - name: myregistrykey
like image 1
Viktors Avatar answered Oct 11 '22 01:10

Viktors