今天通过kubernetes的dashboard进行删除有问题或者重启次数太多的pod,发现删不掉,然后就在本地尝试使用terminal进行删除
先获取指定namespace下的所有的pod,根据status与restars查看crash与重启次数太多的pod
$ kubectl.exe get pods --namespace rubikt
NAME READY STATUS RESTARTS AGE
application-55dc49b47f-tmh2q / Running 10d
application-6969cd9d98-fkmsl / Running 50d
appointment-774cddb446-m8pw9 / Running 30d
appointment-79c88c5c78-w4d2x / Running 50d
config-744f9b8c8d-5vn4q / Running 42d
dynamic-698c8f6857-lgsx4 / Running 40s
dynamic-6d4bd7748d-dc6sc / Running 9d
feedback-6c76f8ff4c-zcz9g / Running 50d
feedback-7d46f789b9-tqqks / Running 42d
gateway-5485b8fbf-mkgmv / Running 42d
gateway-86584799f-kvvsh / Running 50d
hospital-74d8c8765b-lnv8w / Running 50d
hospital-8579ff984d-f8wp8 / CrashLoopBackOff 2d6h
message-59f877688c-cb2qb / Running 50d
使用命令进行删除时,提示该pod没找到
$ kubectl.exe delete pod render-sample-8b4b97bd9-v8p4z --force --grace-period=
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.
Error from server (NotFound): pods "render-sample-8b4b97bd9-v8p4z" not found
可能是没有找到对应的pod,所以可以通过指定namespace来进行删除
$ kubectl.exe delete pod dynamic-698c8f6857-ngb79 --namespace=rubikt --grace-period= --force
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 "dynamic-698c8f6857-ngb79" force deleted
这样就删除了指定的pod