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:
Ingress nginx setup:
ingress-nginx NodePort 10.102.152.58 <none> 80:30692/TCP,443:32297/TCP 6d2h
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:
ubuntu@ip-10-0-20-81:~/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:
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:
Application is correctly deployed and available through the service that is exposed (ClusterIP) from the inside of kubernetes cluster
DNS gets resolved properly to the ELB
HealthCheck on ELB works
Not sure what else could I do to troubleshoot why I'm unable to access my service through Ingress?
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