service "ingress-nginx-controller-admission" not found

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 "": Post https://ingress-nginx-controller-admission.ingress-nginx.svc:443/networking/v1beta1/ingresses?timeout=10s: service "ingress-nginx-controller-admission" not found

It might sound puzzling at first.

This error means that the nginx ingress controller is not responding, it is most likely cause is because you might have uninstalled it by removing the namespace. If this is what you did, you should also delete the ValidatingWebhookConfiguration:

$ kubectl delete -A ValidatingWebhookConfiguration ingress-nginx-admission "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 you haven't completely wiped all the objects that were installed, you would also like 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