1
votes

I am trying to create an ingress controller that points to a service that I have exposed via NodePort.

Here is the yaml file for the ingress controller (taken from https://kubernetes.io/docs/tasks/access-application-cluster/ingress-minikube/):

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: example-ingress
spec:
  rules:
  - host: hello-world.info
    http:
      paths:
      - path: /
        backend:
          serviceName: appName
          servicePort: 80

I can connect directly to the node port and the frontend is displayed.

Please note that I am doing this because the frontend app is unable to connect to other deployments that I have created and I read that an ingress controller would be able to solve the issue. Will I still have to add an Nginx reverse proxy? If so how would I do that? I have tried adding this to the nginx config file but with no success.

location /middleware/ {
      proxy_pass http://middleware/;
   }
1
What is the URL you are getting 404 from?Faheem
Thanks for your reply! I get the 404 from the minikube ip address. I get such url when running kubectl get ingressHonoredTarget
Have you updated your hosts file? hello-world.info won't work since it's won't be resolved by the host.Faheem
Thanks for your reply! I decided to skip using the actual name and just go straight to the ip. Could that be the issue?HonoredTarget
Yeap. In case of IP you need to a catch all Ingress. Adding my answer belowFaheem

1 Answers

2
votes

You must use a proper hostname to reach the route defined in the Ingress object. Either update your /etc/hosts file or use curl -H "hello-world.info" localhost type command. Alternatively, you can delete the host mapping and redirect all traffic to one default service.

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: example-ingress
spec:
  rules:
  - http:
      paths:
      - path: /
        backend:
          serviceName: appName
          servicePort: 80