Kubernetes Ingress 重定向设置
我有一个 avi Kubernetes 入口,想要将 / 重定向到 /ui 。是否可以对 Ingress 路由规则进行操作。
poc.xxx.com/ -->如何重定向到poc.xxx.com/ui
poc.xxx.com/ui --> ui-service
poc.xxx.com/backend -->后端服务
我的入口 Yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: poc-ingress
spec:
rules:
- host: poc.xxx.com
http:
paths:
- path: /ui
pathType: Prefix
backend:
service:
name: ui-service
port:
number: 443
- path: /backend
pathType: Prefix
backend:
service:
name: backend-service
port:
number: 443
I have a avi Kubernetes ingress and want to redirect / to /ui . Is it possible to do on Ingress routing rules.
poc.xxx.com/ --> How to redirect it to poc.xxx.com/ui
poc.xxx.com/ui --> ui-service
poc.xxx.com/backend --> backend-service
My ingress Yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: poc-ingress
spec:
rules:
- host: poc.xxx.com
http:
paths:
- path: /ui
pathType: Prefix
backend:
service:
name: ui-service
port:
number: 443
- path: /backend
pathType: Prefix
backend:
service:
name: backend-service
port:
number: 443
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您执行类似的操作,
/
上的任何请求都会转移到ui
服务,但是如果您正在寻找重定向解决方案,您可以按照以下选项
添加此注释在 ingress 中:
如果请求来自
/
,它将根据您的意愿重定向到另一个域或ui
路径。您还可以创建两个入口,如下所示,第一个入口检查
backend
和/
,而另一个入口处理ui
:不要忘记使用ingress 中的 ingress 类注释。
What if you do something like this, any request at
/
will get moved toui
serviceHowever still if you are looking for a redirect solution you can follow below option
Add this annotation in ingress :
if request comes at
/
it will get redirected to another domain orui
path as you wish.You can also create the two ingress looks like this, first one check
backend
and/
while another one handlesui
:Do not forget to use the ingress class annotation in ingress.