Ram
Ram

Reputation: 693

Kubernetes- How to set up Ingress?

 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?

Upvotes: 3

Views: 2872

Answers (2)

Ram
Ram

Reputation: 693

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*

Upvotes: 0

Vikram Hosakote
Vikram Hosakote

Reputation: 3664

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.

Upvotes: 2

Related Questions