K8s - Unable to reach application from outside the cluster

4/24/2021

I am learning to deploy applications on private clusters. The application is up and running in a pod and is reachable from the node itself. I have created an ingress controller service as well, but I am not sure what's going wrong. The external IP of the nginx-ingress service always returns 404. Any ideas on the fix ?

Services running :

enter image description here

Application service :

enter image description here

Nginx service :

enter image description here

Application ingress :

enter image description here

Ingress yaml : enter image description here

-- Kshitij Karandikar
amazon-eks
kubernetes
kubernetes-ingress
kubernetes-pod
nginx-ingress

1 Answer

4/24/2021

Looks like the Ingress is not being served by your Nginx Ingress controller at the moment. If the Ingress is served by a controller, it should have at least one IP Address under its status.loadBalancer (which should be the external IP used by the Ingress Controller which is serving it), while in your case, looks empty like this:

status:
  loadBalancer: {}

The most common problem on this regard is that the Ingress does not define an Ingress Class or there is no default Ingress Class in the cluster.

First of all, do a k get IngressClass and see if there's any Ingress Class defined. in your cluster. Depending on the Kubernetes version and Ingress Controller version, it could make use of IngressClass objects or simply use annotations (or both).

I would try simply adding the annotation kubernetes.io/ingress.class: nginx under the Ingress metadata as the nginx class is usually the one defined by the Nginx Ingress Controller. Or, if your Ingress Controller is using a different Ingress Class, I'd try specify that in the annotation, then your setup should work.


If you are curious on what is the purpose of an Ingress Class, it can mostly be used to associate an Ingress resource definition, with an ingress controller. On a Kubernetes cluster, there may be more than one Ingress Controller, each one with its own ingress class and Ingress resources are associated to one of them by matching the requested ingress class.

If an ingress class is not specified, the Ingress uses the default one, which means that the IngressClass annotated to be the default one of the cluster is automatically used.

For more info, check the documentation here ( https://kubernetes.io/docs/concepts/services-networking/ingress/#ingress-class )

-- AndD
Source: StackOverflow