[英]How do I configure Kubernetes Ingress controller to support two services?
I have two services, web-service is running on port 80 and admin-service is running on port 8000. I'd like all http /admin requests to be proxied to admin-service:8000 and all other requests to go to web-service:80. 我有两项服务,Web服务在端口80上运行,而admin-service在端口8000上运行。我希望将所有http / admin请求代理到admin-service:8000,并将所有其他请求发送到web-服务:80。 I've tried the configuration below but it doesn't seem to work.
我尝试了以下配置,但似乎无法正常工作。 I'm also using Google Kubernetes Engine.
我也在使用Google Kubernetes Engine。
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ingress-rules
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.org/redirect-to-https: "True"
spec:
tls:
- secretName: tls-secret
rules:
- http:
paths:
- path: /admin
backend:
serviceName: admin-service
servicePort: 8000
- path: /
backend:
serviceName: web-service
servicePort: 80
Any idea what I might be doing wrong? 知道我做错了什么吗?
looks good, but... does your admin service respond to GET /admin
? 看起来不错,但是...您的管理服务是否响应
GET /admin
? cause unless you use ingress.kubernetes.io/rewrite-target: /
annotation on your ingress, you need to support the URI in your backing service 除非您在入口上使用
ingress.kubernetes.io/rewrite-target: /
批注,否则,您需要在支持服务中支持URI
The way to specify default backend is outside the rules
. 指定默认后端的方法不在
rules
。
I think you should take the web service outside the rule section as specified here: name-based-virtual-hosting (look for "Default Backends") 我认为您应该按照此处指定的规则部分之外的方式使用Web服务: 基于名称的虚拟主机 (查找“默认后端”)
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ingress-rules
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.org/redirect-to-https: "True"
spec:
tls:
- secretName: tls-secret
backend:
serviceName: web-service
servicePort: 80
rules:
- http:
paths:
- path: /admin
backend:
serviceName: admin-service
servicePort: 8000
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.