I have a frontend application built with React and backend on nodejs. Both have a separate Docker image and therefore a separate deployment on k8s (gce).
Each deployment has a corresponding k8s service, let's say fe-serice
and be-service
.
I am trying to setup an Ingress so that both services are exposed on a single domain in the following manner:
/api/*
- are routed tobe-service
- everything else is routed to
fe-service
Here is my yaml file:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: my-ingress
annotations:
ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- host: my-host
http:
paths:
- path: /*
backend:
serviceName: fe-service
servicePort: 80
- path: /api/*
backend:
serviceName: be-service
servicePort: 5000
Here is what I get with curl:
curl [ip] --header "Host: my-host"
-> React app (as expected)
curl [ip]/foo --header "Host: my-host"
-> nginx 404 (why?)
curl [ip]/api --header "Host: my-host"
-> nginx 404 (why?)
curl [ip]/api/ --header "Host: my-host"
-> nodejs app
curl [ip]/api/foo --header "Host: my-host"
-> nodejs app
As far as I can see a part with api/
works fine, but I can't figure out everything else, I tried different combinations with/without wildcards, but it still does not work in the way I want it to work.
What am I missing? Is this even possible? Thanks in advance!