Kubernetes fanout ingress but with the root domain serving the client

12/12/2019

I'm having trouble getting my client container talking to the API container, I was hoping to use a fanout ingress as so:

foo.bar.com/api - routes to API container
foo.bar.com - routes to client container

My setup does render the client no problem, but all calls to the API result in 404s - so it's obviously not working. I think the 404 behaviour is a red herring, it's probably looking for Angular routes that match /api and can't find any, I don't think the routing is even happening. My Ingress yaml is below, I can share any other parts of the config if needed. Any pointers much appreciated!

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  namespace: foo-bar
  name: foo-bar-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
    certmanager.k8s.io/cluster-issuer: letsencrypt-prod
    nginx.ingress.kubernetes.io/from-to-www-redirect: "true"
spec:
  tls:
  - hosts:
    - foo.bar.com
    secretName: tls-secret-prod
  rules:
  - host: foo-bar.com
    http:
      paths:
      - backend:
          serviceName: server
          servicePort: 3000
        path: /api
      - backend:
          serviceName: client
          servicePort: 80
        path: / 
-- Mark
azure-kubernetes
kubernetes
kubernetes-ingress

1 Answer

12/13/2019

As suggested by @HelloWorld in the comments, checking the api server routes revealed the issue to be misconfigured routing in the server not the ingress rules.

-- Mark
Source: StackOverflow