Migrating Spring Cloud Gateway Routing to Kubernetes Ingress Routing Migrating Spring Cloud Gateway Routing to Kubernetes Ingress Routing kubernetes kubernetes

Migrating Spring Cloud Gateway Routing to Kubernetes Ingress Routing


Take a look on Ingress resources definition in Kubernetes.

Such option is not supported by offical Ingress configuration in Kubernetes. But you can use other implemented ingress-gateway which supports spring annotations. Here you can find more information: Spring Cloud Gateway Ingress.

Your Ingress configuration file should include annotations like kubernetes.io/ingress.class: spring.cloud.gateway and spring.cloud.gateway/routes.

Here is example Ingress configuration file:

apiVersion: networking.k8s.io/v1beta1 kind: Ingress metadata:   name: httpbin   namespace: ingress   annotations:     kubernetes.io/ingress.class: spring.cloud.gateway     spring.cloud.gateway/routes: |       predicates:       - Host=httpbin.nlighten.nl       - Path=/{segment}       filters:       - SetPath=/anything/{segment}       - PreserveHostHeader       - SecureHeaders       - name: Retry         args:           retries: 3           statuses: BAD_GATEWAY       uri: lb://httpbin spec:   backend:     serviceName: httpbin     servicePort: 80

Remember to create Ingress in proper namespace. Both gateway and backends must be run in same namespace.