Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
107 views
in Technique[技术] by (71.8m points)

How to kill pods on Kubernetes local setup

I am starting exploring runnign docker containers with Kubernetes. I did the following

  1. Docker run etcd
  2. docker run master
  3. docker run service proxy
  4. kubectl run web --image=nginx

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?

question from:https://stackoverflow.com/questions/43410476/how-to-kill-pods-on-kubernetes-local-setup

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...