Search code examples
azurekubernetesazure-aks

nginx Ingress controller on Kubernetes not able to access


I installed nginx ingress controller on AKS cluster.But not able to access ingress endpoints that are exposed by our app.As per the initial analysis we see that ingress endpoints have been assigned external IP of one of the node where as ingress controller service has different IP.

What I am doing wrong ?

$kubectl get pods --all-namespaces | grep ingress
kube-system  ingress-nginx-58ftggg-4xc56   1/1 Running

$kubectl get svc
kubernetes  CLUSTERIP  172.16.0.1    none(ExternalIP)  443/TCP

$kubectl get ingress
vault-ingress-documentation 10.145.13.456

$kubectl describe ingress vault-ingress-documentation
Name:vault-ingress-documentation
Namespace:corebanking
Address:10.145.13.456
Default backend:default-http-backend:80 (<error:default-http-backend:80 not found)

$kubectl get services -n kube-system | grep ingress
ingress-nginx Loadbalancer 172.16.160.33 10.145.13.456 80:30389/TCP,443:31812/TCP

Solution

  • I tried to reproduce the same in my environment and got below results:

    I have created deployment so it will create replica sets and pods for the particular nodes and we can see the pods are up and running like below:

    Kubectl create -f deployment.yaml
    

    enter image description here

    I have created the deployment for the service file it will access inside of the cluster IP:

    Kubectl create -f service.yaml
    

    enter image description here

    To expose the external IP of the application, I created the ingress rules using Ingress.yaml file. I have added the annotation class for the ingress.yaml file like below:

    annotations:  
    kubernetes.io/ingress.class: nginx  
    

    Here ingress rules will be created with empty address like below:

    enter image description here

    When I try to access the application, I am not able to access. To access the application, add loadBalancer IP with Domain name in /etc/host path.

    enter image description here

    Now I am able to connect the application with service IP, but I am not able to expose to the external IP.

    To expose to the external IP, I added annotation class like below:

    annotations:  
    kubernetes.io/ingress.class: nginx  
    nginx.ingress.kubernetes.io/rewrite-target: /  
    

    After that I have applied the changes in the ingressrules.yaml file:

    kubectl replace –force -f ingress_rules.yaml  
    OR  
    Kubectl create -f ingress_rules.yaml
    

    enter image description here

    Now I am able to see the address of the IP, by using this I am able to access the application.