I've deployed a default nginx ingress controller v1.5.1
via helm (kubernetes.github.io/ingress-nginx v4.4.0
) to my AKS cluster. Running kubernetes v1.24.6
.
I have created the following ingress to reach my app service/pod. The idea is to remove the prefix path (/api/v1
) entirely in the rewrite.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$2
name: my-ingress
namespace: my-namespace
labels:
app: my-app
spec:
ingressClassName: nginx
rules:
- http:
paths:
- path: /api/v1(/|$)(.*)
pathType: Prefix
backend:
service:
name: my-service
port:
number: 8080
This results in a 504 (150s timeout). The app pod is healthy, and when I remove the rewrite-target annotation the controller becomes responsive again.
What is unusual is that I see no request log entries in the controller pod whatsoever when attempting to use the rewrite-target annotation. I've added nginx.ingress.kubernetes.io/enable-rewrite-log: "true"
but it makes no difference.
Following documentation here: https://kubernetes.github.io/ingress-nginx/examples/rewrite/
What am I missing?
The problem was the version of Kubernetes on the cluster. I created a new cluster running v1.23.12
using the same ingress and had no issues with the path rewrite working as expected. To confirm, I tried v1.24.3
and v1.24.6
again on new clusters and in both instances reproduced the timeout.