Kubernetes 无法删除pod实例的排查过程
1. 查看一下现在的容器的运行状态:[root@k8s ~]# kubectl get podsNAMEREADYSTATUSRESTARTSAGEnginx-controller-lv8md1/1Unknown016hngi...
·
1. 查看一下现在的容器的运行状态:
[root@k8s ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-controller-lv8md 1/1 Unknown 0 16h
nginx-controller-sb3fx 1/1 Unknown 2 16h
nginx2-1216651254-4b2dw 0/1 ImagePullBackOff 0 8m
nginx2-1216651254-dbtms 0/1 ImagePullBackOff 0 8m
nginx2-1216651254-fhb4r 0/1 ImagePullBackOff 0 8m
2. 查看有哪些replicationcontroller [简写rc]
[root@k8s ~]# kubectl get rc
NAME DESIRED CURRENT READY AGE
kubia 1 1 0 3h36m
可以直接删除 rc上的 pod
[root@k8s ~]# kubectl delete rc kubia
replicationcontroller "kubia" deleted
3. 查看有哪些services
[root@k8s ~]# kubectl get svc
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes 10.254.0.1 <none> 443/TCP 2d
看到上面没有rc,也没有services,那尝试这样删除所有的pods:
[root@k8s ~]# kubectl delete pods --all
pod "nginx-controller-lv8md" deleted
pod "nginx-controller-sb3fx" deleted
pod "nginx2-1216651254-4b2dw" deleted
pod "nginx2-1216651254-dbtms" deleted
pod "nginx2-1216651254-fhb4r" deleted
但是还是无法删除,查看已经部署的容器;
[root@k8s ~]# kubectl get deployment
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
nginx2 3 3 3 0 16h
[root@k8s ~]# kubectl delete deployment nginx2
deployment "nginx2" deleted
为什么这三个Pod实例没有rc或者services呢,因为创建它的时候是使用run来实现的;
但是剩下的两个实例怎么删除呢?
[root@k8s ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-controller-lv8md 1/1 Unknown 0 20h
nginx-controller-sb3fx 1/1 Unknown 2 20h
因为这两个容器的rc,services都已经删除了,但是还保持这个Unknown状态是由于目标主机无法响应并返回信息导致;既然目标主机都已经宕机了,那就直接移除节点;
[root@k8s ~]# kubectl delete node k8s-node
node "k8s-node" deleted
[root@k8s ~]# kubectl get node
NAME STATUS AGE
k8s Ready 2d
Pod的数量没有减少还是两个:
[root@k8s ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-controller-43qpx 1/1 Running 0 14m
nginx-controller-zsx2q 1/1 Running 0 19m
重新加入k8s-node 节点,需要在k8s-node上重启一下服务:
systemctl restart kubelet
更多推荐
已为社区贡献3条内容
所有评论(0)