How to delete kubernetes pods (and other resources) in the system namespace

前端 未结 2 1330
无人共我
无人共我 2021-02-18 23:59

I have by mistake added a pod in the system namespace \"kube-system\". And then I am unable to remove this pod. It also seems to have created a replica set. Every time delete th

相关标签:
2条回答
  • 2021-02-19 01:03

    If you created the pod using kubectl run, then you will need to delete the deployment (which created the replica set, which created the pod). Otherwise, the higher level controllers will continue to ensure that the objects they are responsible for keeping running stay around in the system, even if you try to delete them manually. Try kubectl get deployment --namespace=kube-system to see if you have a deployment in the kube-system namespace. If so, deleting it should also delete the replica set and the pods that you created.

    0 讨论(0)
  • 2021-02-19 01:03

    If a pod is recreated even after kubectl delete pod-name, it means that the pod is controlled by a higher level kubernetes objects such as Deployment, Replicaset, Replication controller.

    You can use kubectl describe pods pod-name | grep Controllers to find which controller your pod belongs to. You need to delete this higher level object to delete the pod.

    0 讨论(0)
提交回复
热议问题