- Newest
- Most votes
- Most comments
The problem was with kyverno-resource-mutating-webhook-cfg and its policy — https://kyverno.io/policies/other/add-emptydir-sizelimit/add-emptydir-sizelimit/
the policy was mutating the spec every time I tried to remove the finalizer and the request was failing deleting the policy & patching the pod to remove finalizer worked, the pod is now deleted
This is a challenging situation with a pod stuck in a Completed state that cannot be deleted. Here are some steps you can try to resolve this issue:
-
Force deletion with kubectl: Try using the kubectl force delete command with a grace period of 0 seconds:
kubectl delete pod <pod-name> --grace-period=0 --forceIf this doesn't work, it's likely due to the finalizer preventing deletion.
-
Patch to remove finalizers: Attempt to remove the finalizers using a JSON patch:
kubectl patch pod <pod-name> -p '{"metadata":{"finalizers":null}}' --type=mergeIf this fails, it's probably because of the API server rejecting changes to the pod spec.
-
Use the API server directly: As a more advanced option, you can try to delete the pod by directly accessing the API server, bypassing some of the normal kubectl validations:
kubectl proxyThen in another terminal:curl -X DELETE localhost:8001/api/v1/namespaces/<namespace>/pods/<pod-name> -d '{"gracePeriodSeconds":0,"propagationPolicy":"Background"}' -H "Content-Type: application/json" -
Check for stuck resources: Investigate if there are any other stuck resources related to this pod or its parent Job. Look for any lingering Job objects, PersistentVolumeClaims, or other resources that might be preventing the pod from being cleaned up.
-
Node issues: If the pod is stuck on a particular node, there might be an issue with that node. Try cordoning the node and draining it to see if that helps resolve the issue.
-
Cluster-wide check: Run a cluster-wide check for any stuck resources or issues that might be preventing normal cleanup operations.
-
EKS version upgrade: Since the pod was created on an earlier version of EKS, consider upgrading your cluster to the latest version if you haven't already. Sometimes, version upgrades can resolve issues with stuck resources.
-
AWS support: If none of these methods work, you may need to contact AWS support for further assistance. They might be able to help resolve the issue at the cluster level.
Remember to be cautious when force deleting resources, as it can potentially lead to inconsistencies in the cluster state. Always ensure you have recent backups before attempting these operations.
Sources
Unable to delete a kubernetes cluster - 1 pods are unevictable | AWS re:Post
Load Balancing - Amazon EKS
Manually quarantine, replace, or reboot a node - Amazon SageMaker
Relevant content
asked 3 years ago
asked 2 years ago
asked 2 years ago
- AWS OFFICIALUpdated 3 years ago
