I already have on my Ingress a lot of domains with so many paths as this is an environment with many microservices.
How can I edit my ingress in some way that when someone access to path /servicex
it gets instead /serviceb
for example
My current ingress is as follow (for simplicity I'm omitting some path from other hosts)
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: main-ingress
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "true"
nginx.ingress.kubernetes.io/force-ssl-redirect: "false"
nginx.ingress.kubernetes.io/proxy-body-size: "100m"
nginx.ingress.kubernetes.io/max-worker-connections: "0"
nginx.ingress.kubernetes.io/max-worker-open-files: "0"
nginx.ingress.kubernetes.io/client-header-buffer-size: "4k"
spec:
tls:
- hosts:
- subdomain-a.domain.com
- subdomain-b.domain.com
- subdomain-c.domain.com
- subdomain-d.domain.com
- subdomain-e.domain.com
secretName: domain-com-secret
rules:
- host: subdomain-a.domain.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: default-service
port:
number: 80
- path: /serviceb
pathType: Prefix
backend:
service:
name: b-service
port:
number: 80
- path: /servicec
pathType: Prefix
backend:
service:
name: c-service
port:
number: 80
- path: /serviced
pathType: Prefix
backend:
service:
name: d-service
port:
number: 80
- path: /servicee
pathType: Prefix
backend:
service:
name: e-service
port:
number: 80
- path: /servicee
pathType: Prefix
backend:
service:
name: e-service
port:
number: 80
- path: /servicef
pathType: Prefix
backend:
service:
name: f-service
port:
number: 80
- path: /serviceg
pathType: Prefix
backend:
service:
name: g-service
port:
number: 80
- host: subdomain-b.domain.com
< tons of other rules >
- host: subdomain-c.domain.com
< tons of other rules >
- host: subdomain-d.domain.com
< tons of other rules >
- host: subdomain-e.domain.com
< tons of other rules >
In other words we want to get access to the /serviceb
if the user enters any of the following:
- https://subdomain-a.domain.com/serviceb -> nothing to do here as we already have this covered
- https://subdomain-a.domain.com/servicex -> this should be transformed into https://subdomain-a.domain.com/serviceb
I have reviewed the rewrite option but its seems to me that if I add the annotation nginx.ingress.kubernetes.io/rewrite-target: /servicex/$2
for example and then try to do something like:
- path: /serviceb(/|$)(.*)
pathType: Prefix
backend:
service:
name: serviceb
port:
number: 80
Won't work because first, we already have that path taken and second I think that the annotation will apply to the whole thing and this will damage all the other routes.
Thanks in advance, any help would be appreciated