Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Delete pods using kubectl containing a substring

When I run the command kubectl get pods | grep "apisix", I get the following data

apisix-dev-78549978b7-pvh2v                           1/1     Running             6 (4m19s ago)   8m14s
apisix-dev-dashboard-646df79bf-mwkpc                  1/1     Running             6 (4m35s ago)   8m12s
apisix-dev-etcd-0                                     1/1     Running             0               8m12s
apisix-dev-etcd-1                                     1/1     Running             0               8m11s
apisix-dev-etcd-2                                     0/1     CrashLoopBackOff    4 (24s ago)     8m11s
apisix-dev-ingress-controller-58f7887759-28cm9        1/1     Running             0               8m11s
apisix-dev-ingress-controller-6cc65c7cb5-k6dx2        0/1     Init:0/1            0               8m9s

Is there any way to delete all the pods containing the word apisix instead of mentioning every pod name in kubectl delete command?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can run a simple command:

kubectl delete pod $(kubectl get pod | grep apisix | awk '{print $1}')
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading