【问题标题】:How to pull ACR image from k3s pods如何从 k3s pod 中提取 ACR 图像
【发布时间】:2021-07-12 06:20:13
【问题描述】:

我已自定义 coredns 映像并将其推送到我的 azure 容器注册表 (ACR)。
现在在 k3s 安装后的默认 coredns pod 中,我想使用 my_azure_acr_repo/proj/customize-coredns:latest 图像 而不是 rancher/coredns-coredns:1.8.3。所以我编辑了 coredns 部署kubectl edit deploy coredns -n kube-system 并将我的 acr 图像替换为 Rancher 之一。但是现在 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

如何验证 acr 图像,以便 pod 拉取它?

【问题讨论】:

    标签: kubernetes kubernetes-pod azure-container-registry coredns


    【解决方案1】:

    那是因为您的容器无权从您的私有 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
    

    对于 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
    

    您的部署规范

    spec:
      containers:
        - name: foo
          image: janedoe/awesomeapp:v1
      imagePullSecrets:
        - name: regkey
    
    

    与此相关的更多信息。

    https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod

    【讨论】:

      猜你喜欢
      • 2018-09-05
      • 1970-01-01
      • 2021-05-18
      • 2022-01-11
      • 2020-05-11
      • 2019-06-12
      • 2021-10-12
      • 2021-06-12
      • 2021-09-10
      相关资源
      最近更新 更多