Created
May 31, 2019 13:55
-
-
Save chexov/e09182d8352eab440e3298bf82544306 to your computer and use it in GitHub Desktop.
Delete Namespace Stuck At Terminating State
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Problem | |
Sometimes after deleting a namespace (for example foo), it sticks on “Terminating” state, and when you enter: | |
kubectl delete namespace foo | |
You get: | |
Error from server (Conflict): Operation cannot be fulfilled on namespaces "foo": The system is ensuring all content is removed from this namespace. Upon completion, this namespace will automatically be purged by the system. | |
Solution | |
Let’s get rid of foo namespace! | |
Run this command: | |
kubectl get namespace foo -o json > tmp.json | |
Open tmp.json and remove kubernetes from finalizers. Just save it! | |
Now you need your cluster address: | |
kubectl cluster-info | |
Then run this command: | |
curl -k -H "Content-Type: application/json" -X PUT --data-binary @tmp.json https://[IP]:[PORT]/api/v1/namespaces/approo/finalize | |
Make sure to use your cluster address! | |
Oh! An error! You can’t do this action as anonymous? | |
namespaces "foo" is forbidden: User "system:anonymous" cannot update namespaces/finalize in the namespace "foo" | |
Don’t worry! Use magic kubernetes proxy: | |
kubectl proxy | |
// Starting to serve on 127.0.0.1:8001 | |
::: tip Note: this command won’t finish. So you can use & at the end, or continue in a new terminal. ::: | |
Then, run the last command again, and use proxy IP and Port. | |
Now check your namespaces: | |
kubectl get namespaces | |
Namespace foo has been gone! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment