项目场景:k8s卸载rook后namespace:rook-ceph 一直Terminating
问题描述:
按照:https://rook.github.io/docs/rook/master/ceph-teardown.html
卸载rook后,namespace:rook-ceph 一直Terminating
如下:
root@ubuntu:~# kubectl get ns
NAME STATUS AGE
default Active 3d22h
kube-node-lease Active 3d22h
kube-public Active 3d22h
kube-system Active 3d22h
kubernetes-dashboard Active 3d21h
rook-ceph Terminating 3h15m
解决方案:
kubectl proxy &
kubectl get namespace rook-ceph -o json |jq '.spec = {"finalizers":[]}' > temp.json
curl -k -H "Content-Type: application/json" -X PUT --data-binary @temp.json 127.0.0.1:8001/api/v1/namespaces/rook-ceph/finalize && kill -9 $(pidof kubectl proxy) && rm temp.json
{
"kind": "Namespace",
"apiVersion": "v1",
"metadata": {
"name": "rook-ceph",
"uid": "e7fdaf46-a9fe-4c69-ac30-183113d194d2",
"resourceVersion": "159728",
"creationTimestamp": "2021-02-24T05:06:32Z",
"deletionTimestamp": "2021-02-24T07:46:55Z",
"annotations": {
"kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Namespace\",\"metadata\":{\"annotations\":{},\"name\":\"rook-ceph\"}}\n"
},
"managedFields": [
{
"manager": "kubectl-create",
"operation": "Update",
"apiVersion": "v1",
"time": "2021-02-24T05:06:32Z",
"fieldsType": "FieldsV1",
"fieldsV1": {"f:status":{"f:phase":{}}}
},
{
"manager": "kube-controller-manager",
"operation": "Update",
"apiVersion": "v1",
"time": "2021-02-24T07:47:01Z",
"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":{}}}}}
},
{
"manager": "kubectl-client-side-apply",
"operation": "Update",
"apiVersion": "v1",
"time": "2021-02-24T08:03:24Z",
"fieldsType": "FieldsV1",
"fieldsV1": {"f:metadata":{"f:annotations":{".":{},"f:kubectl.kubernetes.io/last-applied-configuration":{}}}}
}
]
},
"spec": {
},
"status": {
"phase": "Terminating",
"conditions": [
{
"type": "NamespaceDeletionDiscoveryFailure",
"status": "False",
"lastTransitionTime": "2021-02-24T07:47:01Z",
"reason": "ResourcesDiscovered",
"message": "All resources successfully discovered"
},
{
"type": "NamespaceDeletionGroupVersionParsingFailure",
"status": "False",
"lastTransitionTime": "2021-02-24T07:47:01Z",
"reason": "ParsedGroupVersions",
"message": "All legacy kube types successfully parsed"
},
{
"type": "NamespaceDeletionContentFailure",
"status": "False",
"lastTransitionTime": "2021-02-24T07:47:01Z",
"reason": "ContentDeleted",
"message": "All content successfully deleted, may be waiting on finalization"
},
{
"type": "NamespaceContentRemaining",
"status": "True",
"lastTransitionTime": "2021-02-24T07:47:01Z",
"reason": "SomeResourcesRemain",
"message": "Some resources are remaining: cephblockpools.ceph.rook.io has 1 resource instances"
},
{
"type": "NamespaceFinalizersRemaining",
"status": "True",
"lastTransitionTime": "2021-02-24T07:47:01Z",
"reason": "SomeFinalizersRemain",
"message": "Some content in the namespace has finalizers remaining: cephblockpool.ceph.rook.io in 1 resource instances"
}
]
}
}root@ubuntu:~#kubectl get ns
NAME STATUS AGE
default Active 3d22h
kube-node-lease Active 3d22h
kube-public Active 3d22h
kube-system Active 3d22h
kubernetes-dashboard Active 3d21h
root@ubuntu:~#
# 如果上述方法没删除成功,先安装jq再试一下
apt install jq