【Azure K8S | AKS】在中国区AKS上遇见ImagePullBackOff时的替代方案

问题描述

在AKS集群中部署calico时候,遇见 ImagePullBackOff 问题。 在创建POD calico-typha-horizontal-autoscale 时候遇见拉取镜像失败问题。错误消息为:

Failed to pull image "k8s.gcr.io/cluster-proportional-autoscaler-amd64:1.1.2-r2": rpc error: code = Unknown desc = Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

 

问题解答

这个问题的原因是从中国区访问全球的镜像库时,遇见了无法连接的问题。所以需要修改镜像的地址,在中国区有专门为一些基础镜像做的代理库。

比如:k8s.gcr.io  修改成中国区专用的 gcr.azk8s.cn/google_containers/

通常情况下,AKS组件的yaml文件存储在主节点中的 /etc/kubernetes/addons 目录中,以下示例时修改主节点中的 /etc/kubernetes/addons/calico-daemonset.yaml 文件。

修改前:

metadata:
  name: calico-typha-horizontal-autoscaler
  namespace: kube-system
  … …
      containers:
      - image: k8s.gcr.io/cluster-proportional-autoscaler-amd64:1.1.2-r2
        name: autoscaler

修改后:

metadata:
  name: calico-typha-horizontal-autoscaler
  namespace: kube-system
  … …
      containers:
      - image: gcr.azk8s.cn/google_containers/cluster-proportional-autoscaler-amd64:1.1.2-r2
        name: autoscaler

然后,用一下的命令apply这次的改动:

kubectl apply -f /etc/kubernetes/addons/calico-daemonset.yaml

这样,Kubernetes 旧可以拉取镜像并创建POD。

Events:
  Type    Reason     Age    From                                  Message
  ----    ------     ----   ----                                  -------
  Normal  Scheduled  3m11s  default-scheduler       Successfully assigned kube-system/calico-typha-horizontal-autoscaler-5b8f8b8479-rj6ff to k8s-xxx-111-0
  Normal  Pulling    3m8s   kubelet, k8s-xxx-111-0  pulling image "gcr.azk8s.cn/google_containers/cluster-proportional-autoscaler-amd64:1.1.2-r2"
  Normal  Pulled     3m4s   kubelet, k8s-xxx-111-0  Successfully pulled image "gcr.azk8s.cn/google_containers/cluster-proportional-autoscaler-amd64:1.1.2-r2"
  Normal  Created    3m4s   kubelet, k8s-xxx-111-0  Created container
  Normal  Started    3m2s   kubelet, k8s-xxx-111-0  Started container

 

参考资料

Container Registry Proxy : https://github.com/Azure/container-service-for-azure-china/blob/master/aks/README.md#22-container-registry-proxy

 

 

[end]

 

posted @ 2023-08-15 19:33  路边两盏灯  阅读(107)  评论(0编辑  收藏  举报