Score:0

How to cleanup namespace in kubernetes?

kr flag

We have one cluster in aks. Where we deployed consul helm chart in consul namespace. It created many CRDs.

The using these CRDs internally created one more namespace applicationns

When we deleted consul, it deleted.

Then, when we trying to delete applicationns, it stuck in terminating state for a long time.

So, followed this link and deleted the namespace.

Now, when I ran "kubectl get ns", it is not showing but.

kubectl get serviceintentions -n applicationns
NAME           SYNCED   LAST SYNCED   AGE
servi1       True     41d           42d
servi2    True     41d           42d
servi3   True     41d           42d

Please suggest how to cleanup, there are many CRDs like them. Not deleting also.

commands tried

Score:1
at flag

Follow the steps mentioned in How to force delete a Kubernetes Namespace to cleanup the namespace.

After following the document if you find that Custom CRDs are not getting deleted, even after deleting the namespace then follow the below steps:

Perform a kubectl get crd -A -o jsonpath='{.items[*].metadata.finalizers' to check if the delete operation is in deadlock with finalizers set on the CRDs.

In that case, you can perform the following:

$ kubectl patch crd <custom-resource-definition-name> -n <namespace> -p '{"metadata":{"finalizers":[]}}' --type=merge
$ kubectl delete crd <custom-resource-definition-name> -n <namespace>

If you are not able to delete CRDs by following the above procedure then manually edit the CRD by using below command and delete the finalizer section from the CRDs, so that it gets deleted directly.

 $ kubectl edit crd <CRD-Name>

To do a mass delete of all resources in your current namespace context, you can execute the kubectl delete command with the -all flag.

$ kubectl delete --all

To delete all resources from a specific namespace use the -n flag.

$ kubectl delete -n <namespace-name> --all

To delete all resources from all namespaces we can use the -A flag.

$ kubectl delete -A
Mike D avatar
gl flag
`kubectl delete -n <namespace> --all all` See https://stackoverflow.com/a/55838844/1574942
kr flag
Tried but not helpful. Please find the screenshot added above
Jyothi Kiranmayi avatar
at flag
Try manually editing the CRD by using the command **kubectl edit crd <CRD-Name>** and delete the finalizer section from the CRDs, so that it gets deleted directly.
kr flag
No it is not working, the same question in hashicorp: https://discuss.hashicorp.com/t/consul-is-not-cleaning-up/37863
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.