作成したKubernetesのNamespaceを削除しようとしてもTerminatingのまま削除できないのでkubectl replaceコマンドでImperative(命令)的に削除する
1.この記事を書こうと思った背景 Amazon EKS 上で作成した Namespace を kubetcl delete namespace <namespace> と削除しようとしても削除できないことがあった。(ここで削除したい Namespace は argocd) $ kubectl get ns argocd NAME STATUS AGE argocd Terminating 50m $ kubectl get namespace argocd -o json { "apiVersion": "v1", "kind": "Namespace", "metadata": { "creationTimestamp": "2022-05-06T15:36:43Z", "deletionTimestamp": "2022-05-06T16:15:02Z", "labels": { "kubernetes.io/metadata.name": "argocd" }, "name": "argocd", "resourceVersion": "16545", "uid": "7e29177f-2c2c-4583-b027-49946160bf2b" }, "spec": { "finalizers": [ "kubernetes" ] }, "status": { "conditions": [ { "lastTransitionTime": "2022-05-06T16:15:09Z", "message": "All resources successfully discovered", "reason": "ResourcesDiscovered", "status": "False", "type": "NamespaceDeletionDiscoveryFailure" }, { "lastTransitionTime": "2022-05-06T16:15:09Z", "message": "All legacy kube types successfully parsed", "reason": "ParsedGroupVersions", "status": "False", "type": "NamespaceDeletionGroupVersionParsingFailure" }, { "lastTransitionTime": "2022-05-06T16:15:09Z", "message": "All content successfully deleted, may be waiting on finalization", "reason": "ContentDeleted", "status": "False", "type": "NamespaceDeletionContentFailure" }, { "lastTransitionTime": "2022-05-06T16:15:09Z", "message": "Some resources are remaining: applications.argoproj.io has 1 resource instances", "reason": "SomeResourcesRemain", "status": "True", "type": "NamespaceContentRemaining" }, { "lastTransitionTime": "2022-05-06T16:15:09Z", "message": "Some content in the namespace has finalizers remaining: resources-finalizer.argocd.argoproj.io in 1 resource instances", "reason": "SomeFinalizersRemain", "status": "True", "type": "NamespaceFinalizersRemaining" } ], "phase": "Terminating" } } 2.原因の推測 直接的な原因としては、Kubernetes の公式ドキュメントに書かれている、finalizers can block the deletion of dependent object という点だろう。 ...