= How to Forcefully Delete Kubernetes Resources =
**Summary**: This wiki page explains how to forcefully delete Kubernetes resources that are stuck or not responding. \\
**Date**: 5 August 2025 \\
{{tag>kubernetes}}
Sometimes you may encounter Kubernetes resources that are stuck in a terminating state or not responding to normal deletion commands. This wiki page will show you why that is and how to resolve that.
== Finalizers ==
Kubernetes resources can have [[https://kubernetes.io/docs/concepts/overview/working-with-objects/finalizers/ |finalizers]], which are used to perform cleanup tasks before the resource is deleted. If a finalizer is not removed, the resource will remain in a terminating state indefinitely. This can happen if the finalizer's cleanup logic fails or if the controller responsible for it is not functioning correctly. \\
== Forceful Deletion ==
If a resource is stuck in a terminating state, you can use {{{kubectl describe}}} to check for finalizers and then forcefully delete the resource by removing the finalizers. Here’s how you can do it:
# Check the resource status and finalizers
kubectl describe
# Forcefully delete the resource by removing finalizers
kubectl edit
# This will open the resource in your default editor
# Remove the finalizers section from the YAML
# Save and exit the editor
When the finalizer is removed from the object, it either gets deleted immediatley, or you can delete the resource again using {{{kubectl delete }}}
== Example of a finalizer ==
This is an example of a finalizer in a Kubernetes resource, in this case a NiFi Registry client:
apiVersion: nifi.konpyutaika.com/v1
kind: NifiRegistryClient
metadata:
annotations:
argocd.argoproj.io/tracking-id: nifi:nifi.konpyutaika.com/NifiRegistryClient:nifi/nifi-cluster-default-registry-client
creationTimestamp: "2024-11-13T15:53:44Z"
deletionGracePeriodSeconds: 0
deletionTimestamp: "2025-04-10T12:45:47Z"
finalizers:
- nifiregistryclients.nifi.konpyutaika.com/finalizer
generation: 2
labels:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/version: 1.26.0
helm.sh/chart: nifi-cluster-1.9.0
nifiCluster: nifi-cluster.nifi
name: nifi-cluster-default-registry-client
namespace: nifi
resourceVersion: "625085233"
uid: b52aa24c-ada0-469a-af8b-c7cac17375e9
spec:
clusterRef:
name: nifi-cluster
description: NiFi Registry client
status:
id: 263b0c5d-0193-1000-ffff-ffffac554baa
version: 0
You can delete the full finalizers section to forcefully delete the resource:
finalizers:
- nifiregistryclients.nifi.konpyutaika.com/finalizer