How can I make one route public in kubernetes ingress with auth-url set?

Viewed 971

I am playing a little bit with path-based routing via Kubernetes ingresses (we use Nginx ingress). We have one service up and running behind authentication via external service like the one in the first snippet. This service is already used by other services in our ecosystem, however, as the development progresses, the service now has management API and we need to turn off the authentication for specific paths. According to this answer, this is not possible for basic auth and, according to what I have tried (second snippet), it is not possible for authentication via external service either. Is there any other way to allow specific paths without authentication without completely rearchitecting ingresses and domains/paths?

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: path-based-routing-1
  annotations:
    kubernetes.io/tls-acme: "true"
    kubernetes.io/ingress.class: nginx-external
    nginx.ingress.kubernetes.io/auth-url: http://authorizer.dev.svc.cluster.local
spec:
  tls:
  - hosts:
    - 'routing.example.com'
    secretName: routing.example.com
  rules:
  - host: 'routing.example.com'
    http:
      paths:
      - path: /
        backend:
          serviceName: path-based-routing-1
          servicePort: 80
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: path-based-routing-2
  annotations:
    kubernetes.io/tls-acme: "true"
    nginx.ingress.kubernetes.io/auth-type: ""
    kubernetes.io/ingress.class: nginx-external

    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  tls:
  - hosts:
    - 'routing.example.com'
    secretName: routing.example.com
  rules:
  - host: 'routing.example.com'
    http:
      paths:
      - path: /management-api
        backend:
          serviceName: path-based-routing-2
          servicePort: 80
0 Answers
Related