Why is the namespace where my storage operator was deployed stuck in Terminating status?
When you remove a storage configuration from a cluster, the resources such as operator pods and storage classes are removed, but the namespace is stuck in Terminating
status.
Finalizers are preventing the remaining resources in the namespace and the namespace itself from being deleted.
Take the following steps to remove the resources and the namespace.
Do not delete or patch the resource finalizers in the kube-system
namespace.
- Get the namespace that is stuck in
Terminating
status. Make a note of the resources that are listed in themessage: 'Some resources are remaining:
section.
Example output for a NetApp Trident namespaceoc get ns <namespace> -o yaml
status: conditions: - lastTransitionTime: "2021-05-18T17:40:31Z" message: All resources successfully discovered reason: ResourcesDiscovered status: "False" type: NamespaceDeletionDiscoveryFailure - lastTransitionTime: "2021-05-18T17:40:31Z" message: All legacy kube types successfully parsed reason: ParsedGroupVersions status: "False" type: NamespaceDeletionGroupVersionParsingFailure - lastTransitionTime: "2021-05-18T17:40:31Z" message: All content successfully deleted, may be waiting on finalization reason: ContentDeleted status: "False" type: NamespaceDeletionContentFailure - lastTransitionTime: "2021-05-18T17:40:31Z" message: 'Some resources are remaining: tridentbackends.trident.netapp.io has 1 resource instances, tridentnodes.trident.netapp.io has 3 resource instances, tridentversions.trident.netapp.io has 1 resource instances, tridentvolumes.trident.netapp.io has 1 resource instances' reason: SomeResourcesRemain status: "True" type: NamespaceContentRemaining - lastTransitionTime: "2021-05-18T17:40:31Z" message: 'Some content in the namespace has finalizers remaining: trident.netapp.io in 6 resource instances' reason: SomeFinalizersRemain status: "True" type: NamespaceFinalizersRemaining phase: Terminating
- Run the
oc get
command to get the resources that are pending removal. In the example output, thetridentbackends.trident.netapp.io
resource lists 1 resource instance. Repeat this step for each resource that lists instances in themessage
section of the namespace YAML that you retrieved earlier.
Example command for theoc get <resource> -n <namespace>
tridentbackends.trident.netapp.io
resource.
Example outputoc get tridentbackends.trident.netapp.io -n trident
tbe-bhb5r
pvc-26d97ecd-c268-47ff-a2fd-a0a1a51a9e12
- For each resource that lists instances, run the following
kubectl patch
command to remove the finalizers and delete the resource. After all the resources are patched, the namespace is removed.
Example command for thekubectl -n <namespace> patch <resource>/<instance> -p '{"metadata":{"finalizers":[]}}' --type=merge
tridentbackends.trident.netapp.io
resource.kubectl -n trident patch tridentbackends.trident.netapp.io/tbe-bhb5r -p '{"metadata":{"finalizers":[]}}' --type=merge
- After you remove the finalizers on the remaining resources, run the
oc get ns
command to verify that the namespace is removed.oc get ns