官术网_书友最值得收藏!

Deleting Kubernetes resources

If we've done something wrong with the pod, or it may have broken for some reason, there is a simple way to delete a pod using the kubectl delete pod command:

$ kubectl delete pod httpd-8576c89d7-qjd62
pod "httpd-8576c89d7-qjd62" deleted

We can delete all pods using the --all option:

$ kubectl delete pod --all
pod "httpd-8576c89d7-qjd62" deleted
pod "httpd1-c9f7d7fd9-rn2nz" deleted
pod "httpd2-5b4ff5cf57-vlhb4" deleted
Note that if you run kubectl get pods, you will see all the containers running again. The reason for this is that, when we run the kubectl run command, it creates several different Kubernetes resources, which we are going to discuss in the following section.

We can delete Kubernetes resources by running kubectl delete all with the -l option:

$ kubectl delete all -l app=httpd-demo1
deployment "httpd1" deleted
pod "httpd1-c9f7d7fd9-d9w94" deleted

$ kubectl get pods
NAME READY STATUS RESTARTS AGE
httpd-8576c89d7-qjd62 1/1 Running 0 17m
httpd2-5b4ff5cf57-9llkn 1/1 Running 0 15s

This command will delete all Kubernetes with a httpd-demo1 label only. The other two pods will be still available.

Alternatively, we can delete all Kubernetes resources we have created so far by running the kubectl delete all --all command:

$ kubectl delete all --all
deployment "httpd" deleted
deployment "httpd2" deleted
pod "httpd-8576c89d7-ktnwh" deleted
pod "httpd2-5b4ff5cf57-t58nd" deleted
service "kubernetes" deleted
service "nginx-exposed" deleted
主站蜘蛛池模板: 甘德县| 航空| 家居| 晋宁县| 闽清县| 冷水江市| 绥德县| 浙江省| 新源县| 长顺县| 秦安县| 垫江县| 古丈县| 东辽县| 西乌| 浪卡子县| 琼海市| 改则县| 柞水县| 玉屏| 井研县| 台山市| 康定县| 法库县| 岐山县| 隆安县| 永泰县| 新乡县| 阳江市| 民权县| 芦溪县| 张家界市| 垫江县| 松原市| 龙江县| 温泉县| 仲巴县| 神木县| 龙泉市| 安义县| 饶河县|