sol*_*eit 0 kubernetes azure-container-registry coredns kubernetes-pod
我已经自定义了 coredns 映像并将其推送到我的 azure 容器注册表 (ACR)。
现在,在安装 k3s 之后出现的默认 coredns pod 中,我想使用my_azure_acr_repo/proj/customize-coredns:latest
image而不是 rancher/coredns-coredns:1.8.3
. 因此,我编辑了 coredns 部署kubectl edit deploy coredns -n kube-system
,并将我的 acr 映像替换为 rancher one。但现在 coredns pod 无法提取我的 acr 映像并在 pod 描述中给出错误:
Failed to pull image "my_azure_acr_repo/proj/customize-coredns:latest": rpc error:
code = Unknown desc = failed to pull and unpack image "my_azure_acr_repo/proj/customize-coredns:latest":
failed to resolve reference "my_azure_acr_repo/proj/customize-coredns:latest": failed to
authorize: failed to fetch anonymous token: unexpected status: 401 Unauthorized
Run Code Online (Sandbox Code Playgroud)
如何验证 acr 映像,以便 pod 拉取它?
这是因为您的容器无权从您的私有 ACR 中提取映像。
首先,您必须创建机密,以便可以访问 ACR,然后使用以下命令在部署中传递该机密imagePullSecrets
您可以通过此命令创建秘密,请确保替换您的凭据变量
kubectl create secret docker-registry <name> --docker-server=DOCKER_REGISTRY_SERVER --docker-username=DOCKER_USER --docker-password=DOCKER_PASSWORD --docker-email=DOCKER_EMAIL
Run Code Online (Sandbox Code Playgroud)
对于 ACR 来说,它会是这样的
kubectl create secret docker-registry regkey --docker-server=https://myregistry.azurecr.io --docker-username=ACR_USERNAME --docker-password=ACR_PASSWORD --docker-email=ANY_EMAIL_ADDRESS
Run Code Online (Sandbox Code Playgroud)
您的部署规范
spec:
containers:
- name: foo
image: janedoe/awesomeapp:v1
imagePullSecrets:
- name: regkey
Run Code Online (Sandbox Code Playgroud)
与此相关的更多信息。
https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod
归档时间: |
|
查看次数: |
821 次 |
最近记录: |