Nginx Ingress controller - Error when getting IngressClass nginx

Viewed 3500

I have a Kubernetes cluster v1.22.1 set up in bare metal CentOS. I am facing a problem when setting up Nginx Ingress controller following this link.

I followed exactly the same in step 1-3 but got a CrashLoopBackOff error in nginx ingress controller pod. I checked the logs of the pod and found below:

[root@dev1 deployments]# kubectl logs -n nginx-ingress nginx-ingress-5cd5c7549d-hw6l7
I0910 23:15:20.729196       1 main.go:271] Starting NGINX Ingress controller Version=1.12.1 GitCommit=6f72db6030daa9afd567fd7faf9d5fffac9c7c8f Date=2021-09-08T13:39:53Z PlusFlag=false
W0910 23:15:20.770569       1 main.go:310] The '-use-ingress-class-only' flag will be deprecated and has no effect on versions of kubernetes >= 1.18.0. Processing ONLY resources that have the 'ingressClassName' field in Ingress equal to the class.
F0910 23:15:20.774788       1 main.go:314] Error when getting IngressClass nginx: the server could not find the requested resource

I believe I have the IngressClass setup properly as shown in below:

[root@dev1 deployments]# kubectl get IngressClass
NAME    CONTROLLER                     PARAMETERS   AGE
nginx   nginx.org/ingress-controller   <none>       2m12s

So I have no idea why it said Error when getting IngressClass nginx. Can anyone shed me some lights please?

1 Answers

Reproduction and what happens

I created a one node cluster using kubeadm on CentOS 7. And got the same error.

You and I were able to proceed further only because we missed this command at the beginning:

git checkout v1.12.1

The main difference is ingress-class.yaml has networking.k8s.io/v1beta1 in v1.12.1 and networking.k8s.io/v1 in master branch.

After I went here for the second time and switched the branch, I immediately saw this error:

$ kubectl apply -f common/ingress-class.yaml
error: unable to recognize "common/ingress-class.yaml": no matches for kind "IngressClass" in version "networking.k8s.io/v1beta1"

That looks like other resources are not updated to be used on kubernetes v1.22+ yet.

Please see deprecated migration guide - v1.22 - ingress

How to proceed further

  • I tested exactly the same approach on a cluster with v1.21.4 and it worked like a charm. So you may consider downgrading the cluster.

  • If you're not tight to using NGINX ingress controller (supported by Nginx inc, you can try ingress nginx which is developed by kubernetes community. I tested it on v1.22, it works fine. Please find Installation on bare metal cluster.

P.S. It may be confusing, but there are two free nginx ingress controllers which are developed by different teams. Also there's a third option - NGINX Plus which is paid and has more option. Please see here the difference

Related