Search code examples
kuberneteskubernetes-ingressazure-application-gateway

Kubernetes Ingress - Pass only sub path to backend and not full path


I want a Ingress, that routes host.com/abc/xyz to service/xyz. I have the following configuration but its routing host.com/abc/xyz to service/abc/xyz.

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    appgw.ingress.kubernetes.io/connection-draining: "true"
    appgw.ingress.kubernetes.io/connection-draining-timeout: "30"
    appgw.ingress.kubernetes.io/request-timeout: "300"
    appgw.ingress.kubernetes.io/health-probe-status-codes: "200-399, 401"
    kubernetes.io/ingress.class: azure/application-gateway
  generation: 1
  name: serviceAingress
  namespace: pantry-services
spec:
  rules:
  - host: myhost.net
    http:
      paths:
      - backend:
          serviceName: serviceA
          servicePort: 8083
        path: /abc/*
        pathType: Prefix
      - backend:
          serviceName: serviceA
          servicePort: 8083
        path: /abc
        pathType: Prefix

How can I route myhost.net/abc/* to service/* ? the abc should not be included in the backend call. I've tried pathType as ImplementationSpecific too


Solution

  • I solved this using the backend-path-prefix annotation as described here - https://github.com/Azure/application-gateway-kubernetes-ingress/blob/master/docs/annotations.md#backend-path-prefix