application-gateway-kubernetes-ingress icon indicating copy to clipboard operation
application-gateway-kubernetes-ingress copied to clipboard

Path annotation that allows multiple paths.

Open eduardodfmex opened this issue 3 years ago • 3 comments

Is your feature request related to a problem? Please describe.

AGIC limitation required we create one ingress for each API paths available in our Microservices.

  • Language: Java 11.0.2 with Spring Boot 2.5.6

  • Application Gateway Ingress Controller: version 1.0

  • Helm: version 2

  • AKS with Kubenet network

  • Custom IP routing table

Path annotation don't work with multiple path's link.

We need to create two (2) ingresses instead of just create two path rules.

Describe the solution you'd like

Ask: path annotation that allows multiple paths providing a seamless approach used by other ingress controllers (i.e. Nginx)

In the example below we need to create two (2) ingresses instead of just create two path rules.

{{- if .Values.ingress.enabled -}}
{{- $fullName := include "microservice.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
# Ingress for "/microservice/path#"
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: {{ $fullName }}-microservice1
  labels:
    {{- include "microservice.labels" . | nindent 4 }}
  {{- with .Values.ingress.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
    appgw.ingress.kubernetes.io/backend-path-prefix: "/microservice/path001"
  {{- end }}
spec:
  {{- if .Values.ingress.tls }}
  tls:
    {{- range .Values.ingress.tls }}
    - hosts:
        {{- range .hosts }}
        - {{ . | quote }}
        {{- end }}
      secretName: {{ .secretName }}
    {{- end }}
  {{- end }}
  rules:
  - http:
      paths:
      - backend:
          service:
            name: microservice
            port:
              number: 8082
        path: /microservice/path001
        pathType: Prefix
  {{- end }}
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: {{ $fullName }}-microservice2
  labels:
    {{- include "microservice.labels" . | nindent 4 }}
  {{- with .Values.ingress.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
    appgw.ingress.kubernetes.io/backend-path-prefix: "/microservice2/path002"
  {{- end }}
spec:
  {{- if .Values.ingress.tls }}
  tls:
    {{- range .Values.ingress.tls }}
    - hosts:
        {{- range .hosts }}
        - {{ . | quote }}
        {{- end }}
      secretName: {{ .secretName }}
    {{- end }}
  {{- end }}
  rules:
  - http:
      paths:
      - backend:
          service:
            name: microservice2
            port:
              number: 8082
        path: /microservice2/path002
        pathType: Prefix
  {{- end }}

For a sample on the path annotation see this link.

Nginx multiple paths sample link:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: test-ingress-3
  annotations:
    nginx.ingress.kubernetes.io/use-regex: "true"
spec:
  ingressClassName: nginx
  rules:
  - host: test.com
    http:
      paths:
      - path: /foo/bar/bar
        pathType: Prefix
        backend:
          service:
            name: test
            port:
              number: 80
      - path: /foo/bar/[A-Z0-9]{3}
        pathType: Prefix
        backend:
          service:
            name: test
            port:
              number: 80

eduardodfmex avatar Jul 13 '22 20:07 eduardodfmex

@eduardodfmex AGIC/App Gateway doesn't support regex-based path matching as of yet.

For the above, do you need to use backend-path-prefix annotation to override the path?

akshaysngupta avatar Jul 15 '22 18:07 akshaysngupta

@eduardodfmex I agree. AGIC/App Gateway needs to support multiple paths in the Ingress yaml file, while supporting the Prefix pathType. I do think paths can be overridden with the available annotation: appgw.ingress.kubernetes.io/backend-path-prefix: "/". This is a major missing feature in my opinion - unless I am missing something obvious. I am using AKS, so almost everything is configured using helm and yaml files.

jpflick avatar Jul 16 '22 00:07 jpflick

@akshaysngupta In our case we create one ingress for each path, the "pathType: Prefix" in this case is more an example, works for all paths. https://kubernetes.io/docs/concepts/services-networking/ingress/#examples

eduardodfmex avatar Jul 19 '22 16:07 eduardodfmex