I have created an ingress configuration as follows:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-example
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
ingressClassName: nginx
rules:
- host: "exampleapp.com"
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: primary-svc
port:
number: 80
- host: "exampleapp.com"
http:
paths:
- path: "/images"
pathType: Prefix
backend:
service:
name: images-svc
port:
number: 80
- path: "/clips"
pathType: Prefix
backend:
service:
name: clips-svc
port:
number: 80
The expected behavior is as follows:
exampleapp.com
routes toprimary-svc
exampleapp.com/images
routes toimages-svc
exampleapp.com/clips
routes toclips-svc
- However, URLs like
exampleapp.com/blog
orexampleapp.com/xyz
are not defined in my ingress rules. To handle these, I set up a separate service callederror-svc
and aim to redirect those requests toerror-svc
through the default backend service in the ingress controller deployment:
--default-backend-service=default/error-svc
The issue I’m encountering is that these requests are incorrectly directed to primary-svc
instead. Can anyone provide insight into what might be causing this problem? I am operating within a kind cluster that contains two nodes.