Kubenetes POD delete with Pattern Match or Wilcard

Am I missing something to delete POD using Pattern Match or with Wilcard?

When using Kubernetes it is more common to use labels and selectors. E.g. if you deployed an application, you usually set a label on the pods e.g. app=my-app and you can then get the pods with e.g. kubectl get pods -l app=my-app.

Using this aproach, it is easier to delete the pods you are interested in, with e.g.

kubectl delete pods -l app=my-app

or with namespaces

kubectl delete pods -l app=my-app -n default

See more on Kubernetes Labels and Selectors

Set-based selector

I have some pod's running in the name of "superset-react" and "superset-graphql" and I want to search my wildcard superset and delete both of them in one command

I suggest that those pods has labels app=something-react and app=something-graphql. If you want to classify those apps, e.g. if your "superset" varies, you could add a label app-type=react and app-type=graphql to all those type of apps.

Then you can delete pods for both app types with this command:

kubectl delete pods -l 'app-type in (react, graphql)'

You just need to escape the '$1' variable in the awk command:

alias kdpgroup="kubectl get pods -n bi-dev --no-headers=true | awk '/group-react/{print \$1}'| xargs kubectl delete -n bi-dev pod"

I know that escape is boring, and if you want to avoid it you can use as a function in you .bash_profile:

kdpgroup() {
    kubectl get pods -n default --no-headers=true | awk '{print $1}' | xargs kubectl delete pod -n default
}