本文主要是介绍k8s集群pod资源状态显示Terminating或Unknown时无法删除和故障排除,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
文章目录
- 问题描述:
- 解决方案:
- 故障排除:
问题描述:
在k8s集群中利用yaml创建pod资源时,创建的资源显示为Terminating或Unknown
[root@master test]# kubectl get pods
NAME READY STATUS RESTARTS AGE
my-tomcat-57667b9d9-nklvj 1/1 Terminating 0 10h
my-tomcat-57667b9d9-wllnp 1/1 Terminating 0 10h
解决方案:
使用强制删除命令:
kubectl delete pod [pod name] --force --grace-period=0 -n [namespace]
[root@localhost demo]# kubectl delete pod my-tomcat-57667b9d9-nklvj --force --grace-period=0 -n default
warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely.
pod "my-tomcat-57667b9d9-nklvj" force deleted
[root@localhost demo]# kubectl delete pod my-tomcat-57667b9d9-wllnp --force --grace-period=0 -n default
warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely.
pod "my-tomcat-57667b9d9-wllnp" force deleted
故障排除:
查看pod事件
kubectl describe TYPE NAME_PREFIX
查看pod日志(Failed状态下)
kubectl logs POD_NAME
进入pod(状态为running,但是服务没有提供)
kubectl exec –it POD_NAME bash
这篇关于k8s集群pod资源状态显示Terminating或Unknown时无法删除和故障排除的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!