【发布时间】:2021-07-22 17:32:14
【问题描述】:
我有 2 套豆荚。一组监听80/443,另一组监听其他端口。我想使用来自外部负载均衡器的单个 IP 根据端口路由到这些集合中的任何一个。我查看了入口,但它想根据路径进行路由。 / 的路径相同,只是端口不同。这可能吗?
这是我所拥有的:
apiVersion: v1
kind: Service
metadata:
name: website-service
spec:
type: LoadBalancer
selector:
app: website
ports:
- protocol: TCP
port: 80
targetPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: test
spec:
type: LoadBalancer
selector:
app.kubernetes.io/name: test
ports:
- name: port1
nodePort: 32600
port: 1800
protocol: TCP
targetPort: 1801
- name: port1
nodePort: 31060
port: 12582
protocol: TCP
targetPort: 12583
入口配置:
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: ingress-resource
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
rules:
- host: myhost.gcp.io
http:
paths:
- backend:
serviceName: app1
servicePort: 80
path: /
- backend:
serviceName: app2
servicePort: 14789
path: /
【问题讨论】:
-
您是否尝试使用入口对象?你能显示你的 yaml 吗?
-
ingress是你的朋友.. -
我没有尝试过入口,只是因为查看文档看起来路由是基于路径的。在我的情况下,路径是相同的,只是端口和 pod 不同。
-
入口是关键!试一试,让我们知道您遇到的问题
-
试过了。上面编辑。没运气。因为它们都在同一条路径
/上,所以无论使用的端口如何,它都不会路由到其中一个或另一个
标签: kubernetes google-cloud-platform google-kubernetes-engine balance