Unable to setup kubernetes ingress-nginx

2019-03-18 kubernetes amazon-elb kubernetes-ingress nginx-ingress

I'm having troubles setting up kubernetes ingress-nginx in order to expose my app externally. Here are the steps that I did:

Application deployment:

  1. Created namespace called ingress
  2. Deployed statefulset set resource that describes my application (let's call it testapp) in ingress namespace
  3. Created ClusterIP service that makes my app available in the kube cluster (testapp) in ingress namespace

Ingress nginx setup:

  1. Created ingress-nginx controller in namespace ingress
  2. Created ingress-nginx service in namespace ingress
ingress-nginx          NodePort    10.102.152.58   <none>      80:30692/TCP,443:32297/TCP   6d2h
  1. Created ingress resource type in ingress namespace that looks like this
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target:  /
  name: testappingress
spec:
  rules:
  - host: testapp.k8s.myorg.io
    http:
      paths:
      - backend:
          serviceName: testapp
          servicePort: 80
        path: /

If I do describe of ingress resource, I get this:

[email protected]:~/ingress$ kubectl describe ingress testappingress -n ingress
Name:             testappingress
Namespace:        ingress
Address:
Default backend:  default-http-backend:80 (<none>)
Rules:
  Host                      Path  Backends
  ----                      ----  --------
  testapp.k8s.myorg.io
                            /   testapp:80 (<none>)
Annotations:
  kubernetes.io/ingress.class:                 nginx
  nginx.ingress.kubernetes.io/rewrite-target:  /
Events:
  Type    Reason  Age   From                      Message
  ----    ------  ----  ----                      -------
  Normal  CREATE  15m   nginx-ingress-controller  Ingress ingress/testappingress
  Normal  CREATE  15m   nginx-ingress-controller  Ingress ingress/testappingress
  Normal  UPDATE  14m   nginx-ingress-controller  Ingress ingress/testappingress
  Normal  UPDATE  14m   nginx-ingress-controller  Ingress ingress/testappingress

If I check logs from ingress-nginx controller, I get following:

I0317 15:06:00.029706       6 event.go:221] Event(v1.ObjectReference{Kind:"Ingress", Namespace:"ingress", Name:"testappingress", UID:"2c8db73f-48c6-11e9-ae46-12bdb9ac3010", APIVersion:"extensions/v1beta1", ResourceVersion:"1185441", FieldPath:""}): type: 'Normal' reason: 'CREATE' Ingress ingress/testappingress
I0317 15:06:00.039419       6 controller.go:177] Configuration changes detected, backend reload required.
I0317 15:06:00.508433       6 controller.go:195] Backend successfully reloaded.
I0317 15:06:00.568448       6 controller.go:212] Dynamic reconfiguration succeeded.

Route53/ELB classic setup:

  1. Created ELB classic which points to kubernetes cluster instances and exposes port 80
  2. Created Route53 entry in existing hosted zone (CNAME) which points to ELB classic from above.
  3. Setup Health Check on ELB to point to ingress-nginx NodePort service on port: 30692 which works.

When I do:

curl http://testapp.k8s.myorg.io

I don't get any response.

Here is what I've tried to troubleshoot the problem:

If I do:

telnet testapp.k8s.myorg.io 80

It will resolve to my ELB classic DNS name

If I go into any container/pod that exist inside ingress namespace and do following:

curl http://testapp 

I will get appropriate response.

From this I can conclude following:

  1. Application is correctly deployed and available through the service that is exposed (ClusterIP) from the inside of kubernetes cluster

  2. DNS gets resolved properly to the ELB

  3. HealthCheck on ELB works

Not sure what else could I do to troubleshoot why I'm unable to access my service through Ingress?

Answers

Try to setup nginx ingress controller using this

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/mandatory.yaml

This will create the ingress nginx controller with namespace name ingress-nginx and you can test with your ingress menifest file.

It was a mistake on my end. The missing part was following:

On the ELB, I didn't set listeners correctly. So basically, what was needed is to point 80/443 port from ELB to the NodePorts of Ingress Service.

ingress-nginx   ingress-nginx          NodePort    10.96.249.168    <none>        80:32327/TCP,443:30313/TCP   25h

Related