名前空間の状態確認
admin@cluster-node:~$ kubectl get namespaces
NAME STATUS AGE
cert-manager Terminating 19h
該当名前空間内のリソース確認
kubectl get all --all-namespaces | grep cert-manager
# または
kubectl api-resources --verbs=list --namespaced -o name | xargs -r -I {} kubectl get {} -n cert-manager --ignore-not-found
名前空間詳細情報の取得
admin@cluster-node:~$ kubectl get namespace cert-manager -o json > termination-ns.json
JSON構成の編集
取得したJSONファイルからfinalizersセクションを削除します:
{
"apiVersion": "v1",
"kind": "Namespace",
"metadata": {
"annotations": {
"kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Namespace\",\"metadata\":{\"annotations\":{},\"name\":\"cert-manager\"}}"
},
"creationTimestamp": "2023-11-13T12:55:45Z",
"deletionTimestamp": "2023-11-14T08:18:44Z",
"labels": {
"kubernetes.io/metadata.name": "cert-manager"
},
"name": "cert-manager",
"resourceVersion": "8393161",
"uid": "ec907f95-068f-4f82-8adb-401e4fbbef39"
},
// 次のセクションを削除
// "spec": {
// "finalizers": [
// "kubernetes"
// ]
// },
"status": {
"conditions": [
{
"lastTransitionTime": "2023-11-14T08:18:50Z",
"message": "All resources successfully discovered",
"reason": "ResourcesDiscovered",
"status": "False",
"type": "NamespaceDeletionDiscoveryFailure"
},
{
"lastTransitionTime": "2023-11-14T08:18:50Z",
"message": "All legacy kube types successfully parsed",
"reason": "ParsedGroupVersions",
"status": "False",
"type": "NamespaceDeletionGroupVersionParsingFailure"
},
{
"lastTransitionTime": "2023-11-14T08:18:50Z",
"message": "Failed to delete all resource types, 1 remaining: Internal error occurred: error resolving resource",
"reason": "ContentDeletionFailed",
"status": "True",
"type": "NamespaceDeletionContentFailure"
},
{
"lastTransitionTime": "2023-11-14T08:18:50Z",
"message": "All content successfully removed",
"reason": "ContentRemoved",
"status": "False",
"type": "NamespaceContentRemaining"
},
{
"lastTransitionTime": "2023-11-14T08:18:50Z",
"message": "All content-preserving finalizers finished",
"reason": "ContentHasNoFinalizers",
"status": "False",
"type": "NamespaceFinalizersRemaining"
}
],
"phase": "Terminating"
}
}
APIプロキシの起動
admin@cluster-node:~$ kubectl proxy
Starting to serve on 127.0.0.1:8001
API経由での強制削除実行
# finalizersを除去したJSONを使用して更新
admin@cluster-node:~$ curl -H "Content-Type: application/json" -X PUT --data-binary @termination-ns.json http://127.0.0.1:8001/api/v1/namespaces/cert-manager/finalize