如何在 Helm 3 中使用 imagePullSecrets: []

Raj*_*nan 10 kubernetes kubernetes-helm helm-tls

Helm 3 imagePullSecrets: [] secrete 给出错误。

错误:无法从发布清单构建 Kubernetes 对象:错误验证“”:错误验证数据:ValidationError(Deployment.spec.template.spec.imagePullSecrets[0]):io.k8s.api.core.v1.LocalObjectReference 的无效类型:得到“字符串”,预期“地图”

Tek*_*ath 30

I use this setup and works fine.

In deployment.yaml

    spec:
    {{- with .Values.imagePullSecrets }}
      imagePullSecrets:
        {{- toYaml . | nindent 8 }}
    {{- end }}
      containers:
Run Code Online (Sandbox Code Playgroud)

In values.yaml

imagePullSecrets:
  - name: regcred
Run Code Online (Sandbox Code Playgroud)

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>
Run Code Online (Sandbox Code Playgroud)

You can find detailed documentation here


小智 8

在value.yaml中将 imagePullSecret 指定为:

imagePullSecrets: ["yourSecret"]
Run Code Online (Sandbox Code Playgroud)

将导致您收到的错误。错误中的关键信息是:

got "string", expected "map"
Run Code Online (Sandbox Code Playgroud)

清单需要“imagePullSecret”的“map”对象。应该是这样的:

got "string", expected "map"
Run Code Online (Sandbox Code Playgroud)

执行:

imagePullSecrets: [{ name: yourSecret }]
Run Code Online (Sandbox Code Playgroud)

还有助于验证更改:

helm install --dry-run .\mychart
Run Code Online (Sandbox Code Playgroud)