Kubernetes Namespace Operations: Difference between revisions
Jump to navigation
Jump to search
(4 intermediate revisions by the same user not shown) | |||
Line 22: | Line 22: | ||
<syntaxhighlight lang='bash'> | <syntaxhighlight lang='bash'> | ||
kubectl get namespace <errant-namespace> -o json > data.json | kubectl get namespace <errant-namespace> -o json > data.json | ||
</syntaxhighlight> | |||
Edit data.json and remove "kubernetes" finalizer, leave an empty array []: | |||
<syntaxhighlight lang='json'> | |||
{ | |||
"apiVersion": "v1", | |||
"kind": "Namespace", | |||
"metadata": { | |||
"creationTimestamp": "2019-05-14T13:55:20Z", | |||
"labels": { | |||
"name": "something" | |||
}, | |||
"name": "logging", | |||
"resourceVersion": "29571918", | |||
"selfLink": "/api/v1/namespaces/something", | |||
"uid": "e9516a8b-764f-11e9-9621-0a9c41ba9af6" | |||
}, | |||
"spec": { | |||
"finalizers": [ | |||
"kubernetes" | |||
] | |||
}, | |||
"status": { | |||
"phase": "Terminating" | |||
} | |||
} | |||
</syntaxhighlight> | |||
Execute, after replacing <errant-namespace> with the actual name of the namespace: | |||
<syntaxhighlight lang='bash'> | |||
kubectl replace --raw "/api/v1/namespaces/<errant-namespace>/finalize" -f ./data.json | |||
</syntaxhighlight> | </syntaxhighlight> |
Latest revision as of 20:42, 15 June 2020
Internal
Overview
kubectl create ns <namespace-name>
kubectl get namespaces|ns
kubectl delete namespace|ns <namespace-name>
Recipes
Namespace Deleting Stuck in "Terminating" State
Noticed with EKS 1.16.
Solution here:
kubectl get namespace <errant-namespace> -o json > data.json
Edit data.json and remove "kubernetes" finalizer, leave an empty array []:
{
"apiVersion": "v1",
"kind": "Namespace",
"metadata": {
"creationTimestamp": "2019-05-14T13:55:20Z",
"labels": {
"name": "something"
},
"name": "logging",
"resourceVersion": "29571918",
"selfLink": "/api/v1/namespaces/something",
"uid": "e9516a8b-764f-11e9-9621-0a9c41ba9af6"
},
"spec": {
"finalizers": [
"kubernetes"
]
},
"status": {
"phase": "Terminating"
}
}
Execute, after replacing <errant-namespace> with the actual name of the namespace:
kubectl replace --raw "/api/v1/namespaces/<errant-namespace>/finalize" -f ./data.json