无法删除 POD:
kubectl 获取全部
NAME READY STATUS RESTARTS AGE
pod/mycluster-0 0/2 Terminating 0 15h
pod/mycluster-1 0/2 Terminating 0 15h
pod/mycluster-2 0/2 Terminating 0 15h
kubectl delete --force --all pods
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 "mycluster-0" force deleted
pod "mycluster-1" force deleted
pod "mycluster-2" force deleted
kubectl 获取全部
NAME READY STATUS RESTARTS AGE
pod/mycluster-0 0/2 Terminating 0 16h
pod/mycluster-1 0/2 Terminating 0 16h
pod/mycluster-2 0/2 Terminating 0 16h
终止,未终止。
答案1
要清理 pod,您需要删除它们的部署命名空间。
首先通过运行以下命令发现现有部署:
$ kubectl get deployments --all-namespaces
通过运行以下命令删除部署:
$ kubectl delete deployment <NAME>
然后,所有相应的 Deployment Pod 将自行终止。
您还可以尝试通过运行以下命令来删除 pod 中的终结器:
kubectl patch pod <pod-name> -p '{"metadata":{"finalizers":null}}'
此语法用于终止卡在您的机箱中的 pod。