--force
和 --force --grace-period=0
都没用,还是删不掉首先将 namespace 的信息以 json 格式存储
kubectl get namespace vela-system -o json > tmp.json
编辑 tmp.json,删除 spec.finalizers 下的内容,使之变成空数组,其他的不做改动,具体改动如下
删除前:
删除后:
新打开一个终端,输入
curl -k -H "Content-Type: application/json" -X PUT --data-binary @tmp.json http://127.0.0.1:8001/api/v1/namespaces/${NAMESPACE}/finalize
替换一下 namespace,我这边是
curl -k -H "Content-Type: application/json" -X PUT --data-binary @tmp.json http://127.0.0.1:8001/api/v1/namespaces/vela-system/finalize
执行后输出一堆内容,此时再 kubectl get ns | grep vela
已经查不到了,删除成功
{
"kind": "Namespace",
"apiVersion": "v1",
"metadata": {
"name": "vela-system",
"uid": "734e8f18-129b-4731-8000-a6b5de4c4499",
"resourceVersion": "559153399",
"creationTimestamp": "2023-12-25T03:24:57Z",
"deletionTimestamp": "2023-12-25T06:06:00Z",
"labels": {
"kubernetes.io/metadata.name": "vela-system"
},
"managedFields": [
{
"manager": "vela",
"operation": "Update",
"apiVersion": "v1",
"time": "2023-12-25T03:24:57Z",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:metadata": {
"f:labels": {
".": {},
"f:kubernetes.io/metadata.name": {}
}
}
}
},
{
"manager": "kube-controller-manager",
"operation": "Update",
"apiVersion": "v1",
"time": "2023-12-25T06:06:06Z",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:status": {
"f:conditions": {
".": {},
"k:{\"type\":\"NamespaceContentRemaining\"}": {
".": {},
"f:lastTransitionTime": {},
"f:message": {},
"f:reason": {},
"f:status": {},
"f:type": {}
},
"k:{\"type\":\"NamespaceDeletionContentFailure\"}": {
".": {},
"f:lastTransitionTime": {},
"f:message": {},
"f:reason": {},
"f:status": {},
"f:type": {}
},
"k:{\"type\":\"NamespaceDeletionDiscoveryFailure\"}": {
".": {},
"f:lastTransitionTime": {},
"f:message": {},
"f:reason": {},
"f:status": {},
"f:type": {}
},
"k:{\"type\":\"NamespaceDeletionGroupVersionParsingFailure\"}": {
".": {},
"f:lastTransitionTime": {},
"f:message": {},
"f:reason": {},
"f:status": {},
"f:type": {}
},
"k:{\"type\":\"NamespaceFinalizersRemaining\"}": {
".": {},
"f:lastTransitionTime": {},
"f:message": {},
"f:reason": {},
"f:status": {},
"f:type": {}
}
}
}
},
"subresource": "status"
}
]
},
"spec": {},
"status": {
"phase": "Terminating",
"conditions": [
{
"type": "NamespaceDeletionDiscoveryFailure",
"status": "False",
"lastTransitionTime": "2023-12-25T06:06:06Z",
"reason": "ResourcesDiscovered",
"message": "All resources successfully discovered"
},
{
"type": "NamespaceDeletionGroupVersionParsingFailure",
"status": "False",
"lastTransitionTime": "2023-12-25T06:06:06Z",
"reason": "ParsedGroupVersions",
"message": "All legacy kube types successfully parsed"
},
{
"type": "NamespaceDeletionContentFailure",
"status": "False",
"lastTransitionTime": "2023-12-25T06:06:06Z",
"reason": "ContentDeleted",
"message": "All content successfully deleted, may be waiting on finalization"
},
{
"type": "NamespaceContentRemaining",
"status": "True",
"lastTransitionTime": "2023-12-25T06:06:06Z",
"reason": "SomeResourcesRemain",
"message": "Some resources are remaining: helmcharts.source.toolkit.fluxcd.io has 1 resource instances, helmreleases.helm.toolkit.fluxcd.io has 1 resource instances, helmrepositories.source.toolkit.fluxcd.io has 1 resource instances"
},
{
"type": "NamespaceFinalizersRemaining",
"status": "True",
"lastTransitionTime": "2023-12-25T06:06:06Z",
"reason": "SomeFinalizersRemain",
"message": "Some content in the namespace has finalizers remaining: finalizers.fluxcd.io in 3 resource instances"
}
]
}