Home > Software design >  Error when getting IngressClass nginx: "nginx" not found
Error when getting IngressClass nginx: "nginx" not found

Time:10-04

I'm using Kubernetes version: 1.19.16 on bare metal Ubuntu-18.04lts server. When i tried to deploy the nginx-ingress yaml file it always fails with below errors.

Following steps followed to deploy nginx-ingress,

$ git clone https://github.com/nginxinc/kubernetes-ingress.git
cd kubernetes-ingress/deployments

kubernetes-ingress/deployments$ git branch
* main

$ kubectl apply -f common/ns-and-sa.yaml
$ kubectl apply -f rbac/rbac.yaml
$ kubectl apply -f rbac/ap-rbac.yaml
$ kubectl apply -f common/default-server-secret.yaml
$ kubectl apply -f common/nginx-config.yaml

$ kubectl apply -f deployment/nginx-ingress.yaml
deployment.apps/nginx-ingress created
$ kubectl get pods -n nginx-ingress -o wide
NAME                             READY   STATUS   RESTARTS   AGE   IP           NODE          NOMINATED NODE   READINESS GATES
nginx-ingress-75c4bd64bd-mm52x   0/1     Error    2          21s   10.244.1.5   k8s-master    <none>           <none>
$ kubectl -n nginx-ingress get all
NAME                                 READY   STATUS             RESTARTS   AGE
pod/nginx-ingress-75c4bd64bd-mm52x   0/1     CrashLoopBackOff   12         38m

NAME                            READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/nginx-ingress   0/1     1            0           38m

NAME                                       DESIRED   CURRENT   READY   AGE
replicaset.apps/nginx-ingress-75c4bd64bd   1         1         0       38m
$ kubectl logs nginx-ingress-75c4bd64bd-mm52x -n nginx-ingress   
W1003 04:53:02.833073       1 flags.go:273] Ignoring unhandled arguments: []
I1003 04:53:02.833154       1 flags.go:190] Starting NGINX Ingress Controller Version=2.3.1 PlusFlag=false
I1003 04:53:02.833158       1 flags.go:191] Commit=a8742472b9ddf27433b6b1de49d250aa9a7cb47e Date=2022-09-16T08:09:31Z DirtyState=false Arch=linux/amd64 Go=go1.18.5
I1003 04:53:02.844374       1 main.go:210] Kubernetes version: 1.19.16
F1003 04:53:02.846604       1 main.go:225] Error when getting IngressClass nginx: ingressclasses.networking.k8s.io "nginx" not found
$ kubectl describe pods nginx-ingress-75c4bd64bd-mm52x -n nginx-ingress

Events:
  Type     Reason     Age                  From               Message
  ----     ------     ----                 ----               -------
  Normal   Scheduled  3m6s                 default-scheduler  Successfully assigned nginx-ingress/nginx-ingress-75c4bd64bd-mm52x to k8s-worker-1
  Normal   Pulled     87s (x5 over 3m5s)   kubelet            Container image "nginx/nginx-ingress:2.3.1" already present on machine
  Normal   Created    87s (x5 over 3m5s)   kubelet            Created container nginx-ingress
  Normal   Started    87s (x5 over 3m5s)   kubelet            Started container nginx-ingress
  Warning  BackOff    75s (x10 over 3m3s)  kubelet            Back-off restarting failed container

Nginx Ingress controller Deployment file Link for the reference.

As I'm using kubernetes-ingress.git repository main branch, not sure whether main branch is compatible with my Kubernetes version or not.

Can anyone share some pointer to solve this?

CodePudding user response:

I think you missed to install ingress-controller "NGINX" that is why it is not able to identify the same https://github.com/nginxinc/kubernetes-ingress/blob/main/deployments/common/ingress-class.yaml#L4

kubectl apply -f common/ingress-class.yaml 

You can follow thie steps from this document: https://docs.nginx.com/nginx-ingress-controller/installation/installation-with-manifests/

  • Related