2
votes
 I have an application running on 1001. I deployed it to a container in port 80.

How can I use Ingress for that? I tried using NodePort with --targetPort=1001 and and I added 80 in servicePort in Ingress.yaml.

kubectl expose deployment test --target-port=1001 --type=NodePort

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: test-ingress
spec:
  backend:
    serviceName: test
    servicePort: 80

I am getting error

Backend not found- 404

Am I using the correct way or should I need to follow something else?

2
An Ingress resource alone is not sufficient. You also need to deploy an Ingress controller, for example see daemonza.github.io/2017/02/13/…Michael Hausenblas

2 Answers

1
votes

Setup nginx ingress using helm from the official kubernetes charts repo at https://github.com/kubernetes/charts/tree/master/stable/nginx-ingress.

Along with the nginx ingress controller, you'll need an ingress resource too. Refer https://github.com/nginxinc/kubernetes-ingress/tree/master/examples/complete-example for examples.

0
votes

Finally It worked for me. Here are my findings

1) No need of nginx controllers if you are using GCE/GKE

2) PORTS: If you are using container port 80 then service port should be 80.

If the application is exposed to 4000 then NodePort

--port=80
--targetPort=4000

3) If you still see unhealthy status in Ingress. Check your path in health check it could be possible that you are not pointing the required.

Ex: I had to point to /main.html in Request Path of LB*