Home > Blockchain >  Why only / path works in AKS with NGINX Ingress Controller
Why only / path works in AKS with NGINX Ingress Controller

Time:05-04

I had a clean Azure subscription and created AKS using Standard SKU and very basic setup (2 D2as_v4 nodes, default settings). Installed NGINX like:

helm install ingress-nginx ingress-nginx/ingress-nginx

Then put there a dummy app and made it accessible via Ingress ClusterIP service:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: ingress-demo
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ingress-demo
  template:
    metadata:
      labels:
        app: ingress-demo
    spec:
      containers:
      - name: ingress-demo
        image: mcr.microsoft.com/azuredocs/aks-helloworld:v1
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: ingress-demo
spec:
  type: ClusterIP
  ports:
  - port: 80
  selector:
    app: ingress-demo
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: development-ingress
spec:
  ingressClassName: nginx
  rules:
  - http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: ingress-demo
            port: 
              number: 80

This works and I can access the dummy app on the Public IP assigned to my Ingress (link).

Issue:

I cannot access my app using any non-defalt path configuration. I get Error: Request timed out for anything else than /. This Ingress change do not work for me:

- path: /foo

Same issue using regex:

annotations:
  nginx.ingress.kubernetes.io/rewrite-target: /$2
...
    - path: /dev(/|$)(.*)

UPDATE

I have tried multiple fixes suggested in the GitHub issue mentioned by silent.
Using following option makes /foo path work:

--set controller.service.annotations."service\.beta\.kubernetes\.io/azure-load-balancer-health-probe-request-path"=/healthz

But it still doesn't work for regex. To make path like /dev(/|$)(.*) operable you need either change Azure Load Balancer probe from HTTP to TCP (keeping the port) or to install NGINX controller with this flag:

--set controller.service.externalTrafficPolicy=Local

CodePudding user response:

Not quite sure but it sounds like you ran into this issue: https://github.com/Azure/AKS/issues/2903

The solution was posted in this post: https://github.com/Azure/AKS/issues/2903#issuecomment-1109758644

  • Related