Kubernetes 服务 externalTrafficPolicy 重置为 Local

发布于 2025-01-13 22:56:54 字数 878 浏览 3 评论 0原文

在我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

音栖息无 2025-01-20 22:56:54

您能否提供有关 Kubernetes 集群设置的更多详细信息?这是裸机、云管理的 kubeadm 吗?

当您尝试连接到数据库时查看日志以及一些跟踪是否有用?

externalTrafficPolicy LocalCluster 之间的唯一区别是,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 or Cluster is that Cluster 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 the Cluster option.

There is a nice video who really explain this on detail here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文