![Kubernetes LoadBalancer 仅适用于端口 80,不适用于 Google Cloud 上的其他端口](https://linux22.com/image/699233/Kubernetes%20LoadBalancer%20%E4%BB%85%E9%80%82%E7%94%A8%E4%BA%8E%E7%AB%AF%E5%8F%A3%2080%EF%BC%8C%E4%B8%8D%E9%80%82%E7%94%A8%E4%BA%8E%20Google%20Cloud%20%E4%B8%8A%E7%9A%84%E5%85%B6%E4%BB%96%E7%AB%AF%E5%8F%A3.png)
我在 Google Cloud Kubernetes 集群上公开除端口 80 以外的端口时遇到了麻烦。下面是 Kubernetes 服务 yaml 文件,但出于某种原因,只公开了端口 80。我已通过 SSH 进入 pod,可以确认它们正在内部使用下面列出的其他端口提供服务,但它们似乎没有公开。
对这个问题有什么见解或我应该检查什么来调试它?
apiVersion: v1
kind: Service
metadata:
name: my-frontend
namespace: ocr-cluster
labels:
component: ocr
spec:
type: LoadBalancer
selector:
component: ocr
ports:
# Working:
- name: http
port: 80
protocol: TCP
# Not working
- name: rabbit
port: 15672
protocol: TCP
- name: flower
port: 5555
protocol: TCP
答案1
我只能通过在 yaml 文件中手动指定 LoadBalancer 的静态 IP 来解决这个问题。这似乎非常错误,我敢打赌要么是我做错了什么,要么是某个地方有错误。
我的 yaml 文件如下所示:
apiVersion: v1
kind: Service
metadata:
name: ocr-frontend
namespace: ocr-da-cluster
labels:
component: ocr
spec:
type: LoadBalancer
# Unfortunately, we need to specify the IP address here.
loadBalancerIP: 104.154.151.248
...