AKS not deleting orphaned resources

899 views Asked by At

After some time, I have problems with some of our clusters where auto-delete of orphaned resources stop working. So if I remove a deployment nor the replicaset or the pods are removed, or if I remove a replicaset, a new one is created but the previous pods are still there. I can't even update some deployments because that will create a new replicaset+pods.

This is an actual problem as we are creating and removing some resources and relying on auto-child removal.

The thing is that, destroying and creating again a cluster makes it working perfectly and we weren't able to trace to something we did that caused the problem.

I tried to upgrade both master and agent nodes to a newer version and restarting kubelet in agent nodes but that doesn't solve anything.

Could anyone knows where could be the problem or which component is in charge of the cascade deletion of orphan resources?

Does this happen to someone else? It happend to us already in 3 different clusters with different Kubernetes version.

I have tested it creating the test deployment in K8s documentation, and then delete it:

kubectl apply -f https://k8s.io/examples/application/deployment.yaml

kubectl delete deployments.apps nginx-deployment

But the pods are still there.

Thanks in advance

1

There are 1 answers

1
user1809666 On

The problem was caused by a faulty CRD / Admission Webhook. It could seem strange, but a wrong CRD or a faulty pod acting as webhook will make kube-controller-manager fail for all resources (at least in AKS). After removing the CRD's and the faulty webhook it started to work again. (The reason why the webhook was failing is another different thing)