Namespaces
Namespaces provides a mechanism for isolating groups of resources within a single cluster.
- Names of resources need to be unique within a namespace
- Namespace-based scoping is applicable only for namespaced objects and not for cluster-wide objects
Namespaces Stuck in Terminatingโ
When deleting a namespace in Kubernetes, the namespace may remain stuck in terminating status.
$ kubectl get ns
NAME STATUS AGE
default Active 2d
kube-public Active 2d
kube-system Active 2d
my-namespace Terminating 7m
Solutionโ
- Get the namespace manifest
kubectl get ns my-namespace -o yaml > namespace.yaml
- Edit the manifest file and remove all finalizers
namespace.yaml
apiVersion: v1
kind: Namespace
metadata:
name: my-namespace
spec:
finalizers:
status:
phase: Terminating
- Start kubectl proxy
$ kubectl proxy
Starting to serve on 127.0.0.1:8001
- Call namespace finalize API:
curl -H "Content-Type: application/yaml" -X PUT --data-binary @namespace.yaml http://127.0.0.1:8001/api/v1/namespaces/my-namespace/finalize
- Confirm if namespace was deleted
$ kubectl get ns
NAME STATUS AGE
default Active 2d
kube-public Active 2d
kube-system Active 2d