Nimsa
Nimsa

Reputation: 43

kubectl delete all resources except the kubernetes service

Is there a variant of kubectl delete all --all command or some other command to delete all resources except the kubernetes service?

Upvotes: 3

Views: 4117

Answers (1)

Michael Hausenblas
Michael Hausenblas

Reputation: 13941

I don't think there's a built-in command for it, which means you'll have to script your way out of it, something like this (add an if for the namespace you want to spare):

$ for ns in $(kubectl get ns --output=jsonpath={.items[*].metadata.name}); do kubectl delete ns/$ns; done;

Note: deleting a namespace deletes all its resources.

Upvotes: 3

Related Questions