'Finding resouces by namespace

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?



Solution 1:[1]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1