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

  • 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
主站蜘蛛池模板: 延庆县| 涟源市| 大港区| 明光市| 驻马店市| 西宁市| 苍溪县| 康马县| 象山县| 正定县| 扬州市| 万州区| 武夷山市| 达日县| 陵水| 丽水市| 八宿县| 香格里拉县| 阿巴嘎旗| 山阴县| 灵石县| 黎川县| 寻甸| 元氏县| 沙湾县| 恩施市| 青海省| 开原市| 云霄县| 中牟县| 阜城县| 亚东县| 瓮安县| 拉萨市| 四川省| 寻甸| 丹凤县| 措美县| 安达市| 金寨县| 桑日县|