Kubernetes 服务 externalTrafficPolicy 重置为 Local
在我的 Kubernetes 集群设置中,我有一个带有 LoadBlanacer 服务的 Greenplum DB 集群(1 个主节点和 8 个分段节点)。请参考下面的服务配置。
apiVersion: v1
kind: Service
metadata:
labels:
app: greenplum
greenplum-cluster: greenplum-cluster
name: greenplum
spec:
clusterIP: 10.101.251.127
clusterIPs:
- 10.101.251.127
externalIPs:
- 11.4.8.141
externalTrafficPolicy: Cluster
healthCheckNodePort: 32572
ports:
- name: psql
nodePort: 32198
port: 5432
protocol: TCP
targetPort: 5432
selector:
statefulset.kubernetes.io/pod-name: master-0
sessionAffinity: None
type: LoadBalancer
status:
loadBalancer: {}
但是,部署几个小时后,externalTrafficPolicy
值设置为 Local
而不是 Cluster
,这导致无法通过定义的外部 IP 访问服务。这有什么原因吗?即使我编辑服务配置后它也会自动更改。
或者有没有其他方法可以访问这个Greenplum DB(TCP 5432),例如入口?
In my Kubernetes cluster setup, I have a Greenplum DB cluster (one master and 8 segments nodes) with a LoadBlanacer service. Please refer to the below service config.
apiVersion: v1
kind: Service
metadata:
labels:
app: greenplum
greenplum-cluster: greenplum-cluster
name: greenplum
spec:
clusterIP: 10.101.251.127
clusterIPs:
- 10.101.251.127
externalIPs:
- 11.4.8.141
externalTrafficPolicy: Cluster
healthCheckNodePort: 32572
ports:
- name: psql
nodePort: 32198
port: 5432
protocol: TCP
targetPort: 5432
selector:
statefulset.kubernetes.io/pod-name: master-0
sessionAffinity: None
type: LoadBalancer
status:
loadBalancer: {}
However, a few hours after deployment, the externalTrafficPolicy
value is set to Local
instead of Cluster
, which made the service inaccessible via the defined external IP. Is there any reason for this? It changes automatically even after I edit the service configuration.
Or is there any other way to access this Greenplum DB (TCP 5432) such as ingress?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您能否提供有关 Kubernetes 集群设置的更多详细信息?这是裸机、云管理的 kubeadm 吗?
当您尝试连接到数据库时查看日志以及一些跟踪是否有用?
externalTrafficPolicy
Local
或Cluster
之间的唯一区别是,Cluster
将平衡集群中所有 Pod 之间的流量,并在 Pod 之间实现良好的分布。Local
只会在请求从 LB 到达的节点上已部署的 Pod 之间分配流量。另外,使用
Local
将 保留请求的 clientIP,但不保留Cluster
选项。此处有一个很好的视频,详细解释了这一点。
Can you provide more details on your Kubernetes cluster setup? Is this bare-metal, cloud managed, kubeadm?
Would be useful to see the logs when you try to connect to the DB, also some traces?
The only difference between externalTrafficPolicy
Local
orCluster
is thatCluster
will balance the traffic between all pods in the cluster having a nice distribution between your pods.Local
will only distribute the traffic between the pods already deployed on the node where the request land from the LB.Additionally using
Local
will preserve the clientIP of the request but not theCluster
option.There is a nice video who really explain this on detail here.