背景:
在日常paas平台运维工作中需要对rancher平台进行巡检的工作,在巡检时发现在rancher管理界面无法删除异常的pod服务,
处理:
像这样的情况就是k8s集群的pod无法通过默认的方式去删除掉pod服务,这时候只能是手工强制性去删除pod服务。
注:rancher平台怎么切换到kubelet命名行界面指导:
强制删除pod服务,有两种方式:
方式一:
先查询出来需要强制删除掉pod服务,然后再执行强制删除。
查询:
> kubectl get pods -n dit-sup | grep Terminating
dit-sup-upload-6fd555686c-zxz9h 1/1 Terminating 0 167d
强制删除:
> kubectl delete pod dit-sup-upload-6fd555686c-zxz9h --force --grace-period=0 -n dit-sup
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 "dit-sup-upload-6fd555686c-zxz9h" force deleted
方式二:
查询出来整个集群所有异常的pod服务,然后一次性全部删除掉
查询:
> kubectl get pod -A |egrep -v "Run|Completed|Crea|NAMESPACE|NAME" |awk '{print $1,$2}'
ness-portal ness-portal-reservoir-7d8b49f6-h6xv4
default intake-project2-646df8d457-p7jlg
vwts cloud-platform-buiness-54b546577c-xlpwq
删除:
> kubectl get pod -A |egrep -v "Run|Completed|Crea|NAMESPACE|NAME" |awk '{print $1,$2}'|xargs -n2 kubectl delete pod --grace-period=0 --force -n
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 "ness-portal-reservoir-7d8b49f6-h6xv4" force deleted
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 "intake-project2-646df8d457-p7jlg" force deleted
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 "cloud-platform-buiness-54b546577c-xlpwq" force deleted
验证:文章来源:https://www.toymoban.com/news/detail-610550.html
> kubectl get pod -A |egrep -v "Run|Completed|Crea|NAMESPACE|NAME" |awk '{print $1,$2}'
总结:
在日常的paas平台运维工作,会经常遇见大量的pod运行异常的情况,也存在对pod服务进行强制删除的操作,可以参考如上的。文章来源地址https://www.toymoban.com/news/detail-610550.html
到了这里,关于rancher平台上强制删除pod服务操作的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!