Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Do I Delete Orphan Kubernetes Pods

Tags:

kubernetes

I'm running Kubernetes via Docker. Following the tutorial I launched an Nginx POD using kubectl run nginx --image=nginx --port=80. However this seems to create orphaned PODs (without a replication controller). kubectl get rc doesn't return anything and kubectl describe pod nginx-198147104-kqudh shows Replication Controllers: none (kubectl version "v1.2.0+5cb86ee" shows Controllers: ReplicaSet/nginx-198147104 but scaling it to 0 just causes a new Nginx pod to be created, and it can't be deleted).

I would like to be able to delete the Kubernetes managed Nginx container from Docker. I haven't had much luck find out how to delete an orphan pod (without it being recreated...).

Client Version: version.Info{Major:"1", Minor:"0", GitVersion:"v1.0.4", GitCommit:"65d28d5fd12345592405714c81cd03b9c41d41d9", GitTreeState:"clean"}
Server Version: version.Info{Major:"1", Minor:"2", GitVersion:"v1.2.0", GitCommit:"5cb86ee022267586db386f62781338b0483733b3", GitTreeState:"clean"}

like image 360
node42 Avatar asked Mar 21 '16 18:03

node42


People also ask

How do you clean up Kubernetes pods?

If you create pods directly (not via a deployment), you can delete them directly, and they will stay deleted. Pods (that were created directly), deployments, and services can all be deleted independently of one another, order doesn't matter. If you want to delete them but not the namespace, delete them in any order.

How do you remove unknown pods in Kubernetes?

If you just delete the Pods create by a Deployment, then the Pods will be deleted. But they are again recreated by the owner ReplicaSet. If you just delete the ReplicaSet, then the ReplicaSet and it's Pods will be deleted.

How do I delete all pods in a replica set?

To delete a ReplicaSet and all of its Pods, use kubectl delete . The Garbage collector automatically deletes all of the dependent Pods by default.

How do I delete all evicted pods in Kubernetes?

Delete Evicted Pods We can use the kubectl delete pod command to delete any pod in Kuberenetes. But with this command, we need to provide the pod name to delete any particular pod. The above command will delete the pod with name nginx-07rdsz in studytonight namespace and will release all the resources held by that pod.


1 Answers

With v1.2 Kubernetes we use ReplicaSet (a newer form of ReplicationController). Given that you have a ReplicaSet, you must have used a v1.2 client to create it. But it doesn't stop there. What 1.2 actually creates for you is a Deployment which itself manages ReplicaSets.

So what you need to know is kubectl scale deployment or kubectl delete deployment.

Which tutorial are you following?

like image 139
Tim Hockin Avatar answered Nov 07 '22 06:11

Tim Hockin