디버깅 - k8s 네임스페이스 강제 삭제

Kangyeol Kim·2023년 6월 29일
0

문제

  • k8s에서 불필요한 namespace를 지우는 중에 몇몇 namespace가 지워지지 않는 이슈가 있었다. 로그를 확인해 보니 finalization과정에서 waiting하는 시간이 상당히 길었다.
...
			{
                "lastTransitionTime": "2023-06-27T09:09:38Z",
                "message": "All content successfully deleted, may be waiting on finalization",
                "reason": "ContentDeleted",
                "status": "False",
                "type": "NamespaceDeletionContentFailure"
            },
            {
                "lastTransitionTime": "2023-06-27T09:09:38Z",
                "message": "Some resources are remaining: models.mlops.seldon.io has 1 resource instances, servers.mlops.seldon.io has 2 resource instances",
                "reason": "SomeResourcesRemain",
                "status": "True",
                "type": "NamespaceContentRemaining"
            },
            {
                "lastTransitionTime": "2023-06-27T09:09:38Z",
                "message": "Some content in the namespace has finalizers remaining: seldon.model.finalizer in 1 resource instances, seldon.server.finalizer in 2 resource instances",
                "reason": "SomeFinalizersRemain",
                "status": "True",
                "type": "NamespaceFinalizersRemaining"
            }
        ],
        "phase": "Terminating"
    }
  • k8s에서 Finalizers는 API 오브젝트가 시스템에서 삭제되기 전에 정리 동작을 수행할 수 있도록 설계되어 작업이 완료되면 자동으로 제거되면서 삭제되는데 실제 삭제대상인 namespace에는 필드가 그대로 남아있었다.

해결

  • 검색해보니 finalizers 필드를 지우면 강제로 namespace를 지울 수 있어보여서 해당 필드를 지우고, k8s API를 통해 finalize 작업을 마무리시켰다.
$ k proxy
$ curl -k -H "Content-Type: application/json" -X PUT --data-binary @seldon-mesh.json http://127.0.0.1:8001/api/v1/namespaces/seldon-mesh/finalize
$ kubens # 지워졌나 확인

참조

profile
Ph.D. Student @ KAIST / Co-Founder @ Letsur

0개의 댓글