除非我指定特定的标签版本,否则为什么我会得到 ImagePullBackOff?

Why do I get ImagePullBackOff unless I specify specific tag version?

如果我尝试使用来自 Azure 容器注册表的最新版本图像创建 Pod,我会收到 "ImagePullBackOff" 错误。如果我明确指定镜像版本,则 Pod 创建成功。

我已经创建了一个新的 Image Pull Secret,并且可以确认 Kubernetes 正在从 ACR 中拉取镜像,因为 Pod 在设置版本时成功启动。当我将图像名称设置为 ACR_ImageName:latest(或省略 :latest 时,或将 imagePullPolicy 设置为 "Always" 时,pod 无法创建并报告以下错误:请注意我有替换 acr 名称和图像名称

Warning Failed 27m (x3 over 28m) kubelet, aks-agentpool-15809833-vmss000007
Failed to pull image "acrPath/imageName": [rpc error: code = Unknown desc = Error response from daemon: manifest for acrPath/imageName:latest not found: manifest unknown: manifest unknown, rpc error: code = Unknown desc = Error response from daemon: manifest for acrPath/imageName:latest not found: manifest unknown: manifest unknown, rpc error: code = Unknown desc = Error response from daemon: Get https://acrPath/imageName/manifests/latest: unauthorized: authentication required]

这行不通

apiVersion: v1
kind: Pod
metadata:
  name: k8spocfrontend
  labels:
    app: k8spocfrontend
    type: frontend
spec:
  containers:
  - name: k8spocfrontend
    image: dteuwhorizonacrhorizonmain.azurecr.io/k8spocfront:latest
    imagePullPolicy: "Always"
  imagePullSecrets:
  - name: acr-auth-poc

这个有效

apiVersion: v1
kind: Pod
metadata:
  name: k8spocfrontend
  labels:
    app: k8spocfrontend
    type: frontend
spec:
  containers:
  - name: k8spocfrontend
    image: dteuwhorizonacrhorizonmain.azurecr.io/k8spocfront:2617
    imagePullPolicy: "Always"
  imagePullSecrets:
  - name: acr-auth-poc

从下面的 pods 中可以看出,pods 是在设置版本标记时创建的。

k8spocfront-5dbf7544f8-ccnxj | 2/2 | Running | 0 | 33m

您似乎没有带有 latest 标签的图片。基本上我们将最新标签覆盖为最新版本的图像。