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

  • Learn OpenShift
  • Denis Zuev Artemii Kropachev Aleksey Usov
  • 220字
  • 2021-08-13 16:03:52

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
主站蜘蛛池模板: 宁城县| 永定县| 深泽县| 北票市| 高唐县| 金山区| 宁海县| 延安市| 大石桥市| 阳新县| 大邑县| 玛曲县| 犍为县| 黎川县| 吴桥县| 西盟| 秦安县| 长武县| 来凤县| 陇川县| 宜阳县| 永寿县| 海林市| 洛南县| 韶山市| 阳原县| 南皮县| 鸡东县| 修武县| 府谷县| 林周县| 镇康县| 隆昌县| 佛山市| 文昌市| 和静县| 长乐市| 平定县| 叶城县| 遵义市| 滕州市|