1.kubectl get namespace annoying-namespace-to-delete -o json > tmp.json
Then edit Tmp.json and remove"kubernetes"
curl -k -H "Content-Type: application/json" -X PUT --data-binary @tmp.json https://kubernetes-cluster-ip/api/v1/namespaces/annoying-namespace-to-delete/finalize
And it should delete your namespace,
2.Kubernetes forced to delete the terminating state of the pod,namespace manually built kubernetes, using the native dashboard, feel uncomfortable, The Administration Web page for Kubernetes was then proxied using Rancher2.0. For unknown reasons, the rancher service cannot be enabled, and the rancher dependent namespace (Cattle-system) is removed, and the state is always terminating. This is the background. Workaround:
- You can use the Force Delete command in Kubectl
# Delete pod Kubectl Delete pod podname--force--grace-period=0
# Delete Namespace Kubectl Delete namespace NamespaceName--force--grace-period=0
|
- If the above method cannot be deleted, the second method can be used to delete the source data directly from the ETCD ( This is one of the most violent ways, we do not recommend the direct operation of the data in the ETCD, before the operation please confirm that you know what you are doing. )
# Remove the pod named pod-to-be-deleted-0 under the default namespace Etcdctl_api=3 Etcdctl del/registry/pods/default/pod-to-be-deleted-0
# Delete namespace that need to be deleted Etcdctl Del/registry/namespaces/namespacename
|
Kubernetes namespace terminating