Kubernetes: nginx ingress controller - failed calling webhook

2 min read

On a kubernetes cluster you might find the following error:

$ kubectl apply -f ingress.yaml 
Error from server (InternalError): error when creating "ingress": Internal error occurred: failed calling webhook "validate.nginx.ingress.kubernetes.io": Post https://ingress-nginx-controller-admission.ingress-nginx.svc:443/networking/v1beta1/ingresses?timeout=10s: service "ingress-nginx-controller-admission" not found

This error means that the nginx ingress controller is not responding: This can be due to the fact that it might have uninstalled it by removing the namespace but the ValidatingWebhookConfiguration was not. So, to remove the ValidatingWebhookConfiguration you just need to remove the ingress-nginx-admission object:

$ kubectl delete -A ValidatingWebhookConfiguration ingress-nginx-admission
validatingwebhookconfiguration.admissionregistration.k8s.io "ingress-nginx-admission" deleted

Once you have it removed, you will be able to create ingress objects as usual:

$ kubectl apply -f ingress.yaml
ingress.extensions/testingress created

Be aware that by removing the nginx ingress controller namespace and the ingress-nginx-admission webhook you are not completely removed all the objects that were installed with the nginx ingress controller: You also want to check for the presence of some clusterroles and clusterrolebindings to also get rid of them:

$ kubectl get clusterrole | grep nginx
ingress-nginx                                                          2021-01-26T19:23:38Z
ingress-nginx-admission                                                2021-01-26T19:23:47Z
$ kubectl get clusterrolebinding | grep nginx
ingress-nginx                                          ClusterRole/ingress-nginx                                          7d20h
ingress-nginx-admission                                ClusterRole/ingress-nginx-admission                                7d20h

Posted on 26/02/2021