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

2021-02-19 14:21:39 浏览数 (1)

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

代码语言:javascript复制
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信息提示镜像是

代码语言:javascript复制
k8s.gcr.io/ingress-nginx/controller:v0.41.2@sha256:1f4f402b9c14f3ae92b11ada1dfe9893a88f0faeb0b2f4b903e2c67a0c3bf0de

后边多出来了@sha256:1f4f40......这些,所以才不认我们导入的镜像 解决问题: 通过修改Pod的yaml信息,修改镜像,将@sha256:1f4f40......这些删除保存后,Pod修复正常了

代码语言:javascript复制
[root@master1 ~/Yii]#kubectl edit pods -n ingress-nginx ingress-nginx-controller-5dbd9649d4-bzdgc 
pod/ingress-nginx-controller-5dbd9649d4-bzdgc edited

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

代码语言:javascript复制
ingress-nginx          ingress-nginx-controller-5dbd9649d4-bzdgc    1/1     Running            0          12d
ingress-nginx          nginx-ingress-controller-54b86f8f7b-5lbb8    1/1     Running            0          50d

0 人点赞