I deployed service called "test" in kubernetes. service name : test port : 80
There is endpoint called "/abc"
ingress.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: load-balancer
spec:
rules:
- http:
paths:
- path: /test/*
backend:
serviceName: test
servicePort: 80
API call "http://ip-address/test/abc" given 404 error. But endpoint "/test/abc" working properly.
I need skip "/test" when routing. How I do this.
In this ingress definition, any characters captured by (. *) will be assigned to the placeholder $2 , which is then used as a parameter in the rewrite-target annotation. For example, the ingress definition above will result in the following rewrites: rewrite.bar.com/something rewrites to rewrite.bar.com/
A new pathType field that can specify how Ingress paths should be matched. A new IngressClass resource that can specify how Ingresses should be implemented by controllers. Support for wildcards in hostnames.
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$2
name: rewrite
namespace: default
spec:
rules:
- host: rewrite.bar.com
http:
paths:
- backend:
serviceName: http-svc
servicePort: 80
path: /something(/|$)(.*)
In this ingress definition, any characters captured by (.*) will be assigned to the placeholder $2, which is then used as a parameter in the rewrite-target annotation.
For example:
rewrite.bar.com/something
rewrites to rewrite.bar.com/
Source: https://github.com/kubernetes/ingress-nginx/blob/master/docs/examples/rewrite/README.md.
You're looking for url rewriting feature. It's currently only supported on nginx-ingress (not GKE ingress). https://github.com/kubernetes/ingress-nginx/blob/master/docs/examples/rewrite/README.md.
But you can install nginx-ingress controller on GKE if you want, there's documentation on how to do that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With