我有一个包含大量图像的私人 Docker 存储库。我正在使用 Helm 将它们部署到 Kubernetes 集群。
Helm value.yaml 包含存储库凭据:
image:
repository: <repo>
tag: <version tag>
pullPolicy: IfNotPresent
imageCredentials:
registry: <repo>
username: <username>
password: <pw>
完成 helm 安装后
helm install myhelmchart --values value.yaml --version
Pod 的状态为 Init:ErrImagePull。
kubectl 描述 pod 给出以下错误:
无法拉取镜像“image:tag”:rpc 错误:代码 = 未知 desc =
来自守护程序的错误响应:获取 [image]/manifests/[version]:
未授权:需要身份验证
这取决于您的舵图的输出。您可以使用helm template
查看生成的 kubernetes 资源,而无需实际部署它。使用私有 docker 注册表中的镜像分为两个步骤:
-
确保您有一个secret资源 https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/#create-a-secret-in-the-cluster-that-holds-your-authorization-token对于私有存储库。注意这里的类型是kubernetes.io/dockerconfigjson
or kubernetes.io/dockercfg
.
描述了如何使用 helm 中的模板创建此内容here https://helm.sh/docs/howto/charts_tips_and_tricks/#creating-image-pull-secrets.
- 在使用该私有存储库中的映像的 Pod 中引用该 Secret,如下所示:
Pod 资源/模板:
spec:
containers:
- name: some-pod
image: <image>
imagePullSecrets:
- name: <name-of your secret>
您可以先手动构建资源,无需 Helm。这有助于验证资源本身是否正确。然后,您可以根据您的值调整 helm 模板以输出正确的资源。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)