I have a K3s cluster with system pods (i.e. kube-system
namespace) and my application pods:
kube-system pod/calico-node-xxxx
kube-system pod/calico-kube-controllers-xxxxxx
kube-system pod/metrics-server-xxxxx
kube-system pod/local-path-provisioner-xxxxx
kube-system pod/coredns-xxxxx
app-system pod/my-app-xxxx
db-system pod/my-db-xxxxx
I am looking for a shell/kubectl command (for automation script) that can delete my application namespace (want to modify kubectl delete namespace app-system db-system
) without mentioning the app namespaces name in the command (as in future if more app namespace would come in cluster, I have to edit this script every time).
That means I want to delete all namespace in cluster except kube-system
something like - kubectl delete namespace -v kube-system
(I know -v
is not a valid parameter here, just showing how in grep -v
is used to except the following words. Similar thing looking for kubectl delete ns...
)