Route management with Zuul + Kubernetes Discovery Client

What I learned today — 24 April 2018

Niel de Wet
1 min readApr 24, 2018

Suppose you run your microservices application behind a Netflix Zuul API Gateway on Kubernetes infrastructure. Suppose further you have two services, my-ui and my-backend, as well as my-backend-db. The API Gateway is available at api-gateway

Using the Kubernetes Discovery Client Zuul will automatically detect routes for the four services. You can configure Zuul with a route prefix, like /api, which tells it to recognise routes like /api/my-backend as /my-backend. You can further configure it to strip the prefix before passing the request to the backend service. We want to ignore the my-ui service (we’ll serve that separately), and all services that end with -db. Lastly, we don’t want the API Gateway to route to itself, so we’ll exclude that route as well. The application.yaml file will now contain these properties:

zuul:
prefix: '/api'
ignoredServices:
'api-gateway, my-ui, *-db'
routes:
my-backend:
path:
'/my-backend/**'
serviceId: 'my-backend'
stripPrefix: true

Now you can define an Ingress like this:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name:
my-app
spec:
rules:
- http:
paths:
- path: /api/
backend:
serviceName:
api-gateway
servicePort: web
- path: /
backend:
serviceName:
my-ui
servicePort: web

--

--

Responses (1)