API "stitching" with Kong Ingress?

32 views Asked by At

I have an Ingress for Kong that looks like that, deployed on Kubernetes for a micro-service A :

kind: Ingress
apiVersion: networking.k8s.io/v1
metadata:
  name: ingressName
  annotations:
    kubernetes.io/ingress.class: kong
    konghq.com/strip-path: 'true'
spec:
  tls:
  - hosts:
      - my.host
  rules:
    - host: my.host
      http:
        paths:
          - path: /
            pathType: ImplementationSpecific
            backend:
              service:
                name: serviceName
                port:
                  number: 8080

Something basic, it intercepts every call to my micro-service and calls my backend "serviceName". I now have another micro-service B, but I want to setup my Ingress so that if an endpoint doesn't exist in A, then it calls B. Note that my ingress intercepts every calls, the "endpoint" will always "exist", but might return 404, in which case I want to retry with the other micro-service.

Let's say I have those endpoints for A :

  • /api/abc
  • /api/xyz

and those endpoints for B :

  • /api/xyz
  • /api/new

If I call /api/abc, it has to call A, if /api/xyz, it has to call A and if I call /api/new, it has to call B. However, if I ever add /api/new in A, I want the ingress to call A and not B without having to change anything anywhere.

I know I can do exactly that with Apollo Server with GraphQL Schema Stitching. Can I do something similar here with Kong Ingress?

0

There are 0 answers