1

I am working on a GKE cluster. I have a simple server running. There are three routes on the server.

route 1 - / 
route 2 - /ping
route 3 - /health 

These paths return 200 response with generic but different "ok" messages.

This is what my ingress yaml looks like -

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: basic-ingress
spec:
  tls:
  - hosts:
    - www.simple.com
    secretName: simple-server-tls
  rules:
    - host: www.simple.com
      http:
        paths:
        - path: /ping
          backend:
            serviceName: simple-server
            servicePort: 8080

I have my server exposed as a load balancer. I can access all three routes using loadbalancer as https://<loadbalancer_ip>:8080/ https://<loadbalancer_ip>:8080/ping https://<loadbalancer_ip>:8080/health

However, when trying to use an ingress, I only receive a 200 response on https://www.simple.com/ping The other two routes i.e. https://www.simple.com/health and https://www.simple.com/ return default backend - 404 error.

I can confirm that the server is running and is serving requests perfectly and I have given ingress enough time(upwards of 30 minutes) to finish setting-up. https://www.simple.com/healthz returns "OK".

I think I am making a mistake in configuring the ingress correctly. Any help/suggestions are appreciated.

I cannot provide the ingress logs as I am noticing that kubectl describe ingress/basic-ingress returns the error Error from server (NotFound): the server could not find the requested resource However, kubectl get ingress returns basic-ingress www.simple.com <ingress_ip> 80, 443 31m

goldentiger
  • 67
  • 2
  • 8
  • You're rewriting all URLs as /. Remove the rewrite-target annotation, and it should work. – Burak Serdar Oct 09 '19 at 23:26
  • I did try that. I had my ingress configured with `path /health`. If I was rewriting the URL, I should have received the response for `path /`. However in that case, I was receiving 404 on `path /` and `path /ping`. Only `path /health` was working. – goldentiger Oct 09 '19 at 23:30
  • If you configured the ingress for `/health`, all the other urls will be unmapped, so getting 404 is expected. The path is a prefix, anything starting with that path will be proxied. With `/`, you're sending everything, but rewriting them as `/`. Try without the rewrite annotation. – Burak Serdar Oct 09 '19 at 23:37
  • I did try it just now. This solution didn't work. I received 200 on `https://www.simple.com` and 404 on `https://www.simple.com/ping` – goldentiger Oct 09 '19 at 23:41
  • I traced my outgoing HTTP requests and I can confirm that my requests are going out as `GET https://www.simple.com/` and `GET https://www.simple.com/ping` – goldentiger Oct 09 '19 at 23:44
  • You should look at nginx access logs, see what it is trying to do. – Burak Serdar Oct 09 '19 at 23:51
  • checked the logs. Nothing out of the ordinary. Events say Normal Add and Normal Create – goldentiger Oct 10 '19 at 00:02
  • I think there has to be some wild card right? like /*? – goldentiger Oct 10 '19 at 00:10

1 Answers1

1

Figured out the issue. You need to add a wild card to the path. I only had / in my path and hence it was rejecting (read throwing 404 error) for all my other urls. I added /* and removed the rewrite-target annotation as @bserdar correctly suggested and it worked. Link to the issue on github that helped a lot - https://github.com/kubernetes/ingress-nginx/issues/1120

goldentiger
  • 67
  • 2
  • 8
  • Your ingress is GKE ingress. It is not nginx ingress. The rules are different for each ingress implementation. Since it is not nginx, the rewrite-target should also be unnecessary, as afaik, it does not apply to GKE ingress. – Burak Serdar Oct 10 '19 at 00:47