跳到主要内容

K8S删除pod后会自动重新创建问题排查解决

问题复现

在测试k8s集群时,使用了helm安装了一些组件,有些组件由于网络问题一直没下载下来,在pod列表可以看到很多类似ImagePullBackOff的错误。在使用命令手动删除pod后,pod会自动重建。

> kubectl get pods 
NAME READY STATUS RESTARTS AGE
nginx-ingress-1-controller-7d589df745-bkxcd 1/1 Running 0 157m
ingress-nginx-1-admission-create-j49c8 0/1 ErrImagePull 0 4m3s
ingress-nginx-admission-create-4mps5 0/1 ImagePullBackOff 0 4m13s

排查

列出所有deployment:

kubectl get deployments --all-namespaces

然后删除deployment:

kubectl delete -n NAMESPACE deployment DEPLOYMENT

检查job或daemonset

kubectl get jobs

kubectl get daemonsets.app --all-namespaces

kubectl get daemonsets.extensions --all-namespaces

解决

在jobs中删除对应的job之后问题解决

> kubectl get jobs
NAME COMPLETIONS DURATION AGE
ingress-nginx-admission-create 0/1 21h 21h
ingress-nginx-1-admission-create 0/1 21h 21h

> kubectl delete job ingress-nginx-admission-create
> kubectl delete job ingress-nginx-1-admission-create