Home > Software engineering >  Finding resouces by namespace
Finding resouces by namespace

Time:04-09

I am using kubectl. How to find dangling resources by the namespace?

For example, I have some namespaces.

kubectl get ingress --all-namespaces |awk '{print $1}'

That is supposed to be deleted. If I find those namespaces on GKE there is no result returned.

So why kubectl are me showing those namespaces?

CodePudding user response:

You can find dangling resources on a particular namespace with the following command:

kubectl api-resources --verbs=list --namespaced -o name \
  | xargs -n 1 kubectl get --show-kind --ignore-not-found -n <namespace>

If you need to force the namespace deletion, you can do so by removing the Finalizer:

1.

kubectl get namespace <namespace> -o json > <namespace>.json
kubectl replace --raw "/api/v1/namespaces/<namespace>/finalize" -f ./<namespace>.json
  • Related