refer to this lab module (question 6): Kubernetes Troubleshooting for Application Developers Course | KodeKloud
the yaml file was:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: app-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
rules:
- host: "myapp.com"
http:
paths:
- pathType: Prefix
path: "/blog(/|$)(.*)"
backend:
service:
name: blog-service
port:
number: 80
- pathType: Prefix
path: "/store(/|$)(.*)"
backend:
service:
name: store-service
port:
number: 80
it should redirect to myapp.com/
according to the official documentation: Rewrite - Ingress-Nginx Controller (since the pattern is similar)
but it gives wrong answer:
it takes myapp.com/store/
as right answer.