解决一次K8s的ingress-nginx-controller的Pod为Pending

问题解释:

不知道怎么回事,ingress-nginx-controller就出问题了,Pod状态显示Pending
通过describe查看Pod信息,出现以下报错

Events:
  Type     Reason   Age                      From     Message
  ----     ------   ----                     ----     -------
  Warning  Failed   20m (x74236 over 12d)    kubelet  Error: ImagePullBackOff
  Normal   BackOff  5m22s (x74298 over 12d)  kubelet  Back-off pulling image "k8s.gcr.io/ingress-nginx/controller:v0.41.2@sha256:1f4f402b9c14f3ae92b11ada1dfe9893a88f0faeb0b2f4b903e2c67a0c3bf0de"
  Warning  Failed   1s (x3296 over 12d)      kubelet  Failed to pull image "k8s.gcr.io/ingress-nginx/controller:v0.41.2@sha256:1f4f402b9c14f3ae92b11ada1dfe9893a88f0faeb0b2f4b903e2c67a0c3bf0de": 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)

问题分析:

通过以上信息,可以分析出来需要节点目前需要下载指定版本的镜像,但由于网络问题,下载失败,导致Pod不正常

解决问题:

我们通过技术手段下载镜像,并导入到各Node节点

新出问题:

但是导入后发现Pod还是不行,后来发现describe信息提示镜像是

k8s.gcr.io/ingress-nginx/controller:v0.41.2@sha256:1f4f402b9c14f3ae92b11ada1dfe9893a88f0faeb0b2f4b903e2c67a0c3bf0de

后边多出来了@sha256:1f4f40……这些,所以才不认我们导入的镜像

解决问题:

通过修改Pod的yaml信息,修改镜像,将@sha256:1f4f40……这些删除保存后,Pod修复正常了

[root@master1 ~/Yii]#kubectl edit pods -n ingress-nginx ingress-nginx-controller-5dbd9649d4-bzdgc 
pod/ingress-nginx-controller-5dbd9649d4-bzdgc edited

修改保存后,再次查看Pod,发现已经显示正常了

ingress-nginx          ingress-nginx-controller-5dbd9649d4-bzdgc    1/1     Running            0          12d
ingress-nginx          nginx-ingress-controller-54b86f8f7b-5lbb8    1/1     Running            0          50d

原文出处:myit -> https://myit.icu/index.php/archives/1031/

打赏

如果此文对你有所帮助,请随意打赏鼓励作者^_^