I'm trying to configure NGINX Ingress controller as the correct entry point to my Kubernetes cluster. Inside the cluster, I've created two REST Web services as well as frontend application. I'm trying to achieve the following scenario.
192.168.1.20
should lead to frontend service on port 80.192.168.1.20/first-rest/api/flower?id=1
should route the request to the first-rest service so that it could return the flower with id = 1. apiVersion: networking.k8s.io/v1beta1 kind: Ingress metadata: name: main-routes annotations: kubernetes.io/ingress.class: nginx nginx.ingress.kubernetes.io/ssl-redirect: "false" nginx.ingress.kubernetes.io/use-regex: "true" nginx.ingress.kubernetes.io/rewrite-target: /$1 spec: rules: - http: paths: - path: /first-rest(/|$)(.*) backend: serviceName: first-rest servicePort: 8090 - path: /second-rest(/|$)(.*) backend: serviceName: second-rest servicePort: 9000 - path: /(.*) backend: serviceName: frontend servicePort: 80
You need to specify the ingress path type otherwise, depending on the ingress class specific implementation it will default to either exact or prefix (I assume in your case it is defaulting to exact)
So, you need to do something like
spec:
rules:
- http:
paths:
- path: /first-rest
pathType: Prefix
backend:
serviceName: first-rest
servicePort: 8090
see docs on ingress path here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.