I am starting exploring runnign docker containers with Kubernetes. I did the following
To cleanup the state, I first stopped all the containers and cleared the downloaded images. However I still see pods running.
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
web-3476088249-w66jr 1/1 Running 0 16m
How can I remove this?
To delete the pod:
kubectl delete pods web-3476088249-w66jr
If this pod is started via some replicaSet or deployment or anything that is creating replicas then find that and delete that first.
kubectl get all
This will list all the resources that have been created in your k8s cluster. To get information with respect to resources created in your namespace kubectl get all --namespace=<your_namespace>
To get info about the resource that is controlling this pod, you can do
kubectl describe web-3476088249-w66jr
There will be a field "Controlled By", or some owner field using which you can identify which resource created it.
When you do kubectl run ...
, that's a deployment you create, not a pod directly. You can check this with kubectl get deploy
. If you want to delete the pod, you need to delete the deployment with kubectl delete deploy DEPLOYMENT
.
I would recommend you to create a namespace for testing when doing this kind of things. You just do kubectl create ns test
, then you do all your tests in this namespace (by adding -n test
). Once you have finished, you just do kubectl delete ns test
, and you are done.