【问题标题】:Pods running on the same node can't access to each other through service同一节点上运行的 Pod 不能通过 service 相互访问
【发布时间】:2021-01-12 08:30:57
【问题描述】:

我已经使用 kubespray 2.13.2Azure 上安装了一个 kubernetes 集群。 但是在我安装了一些数据平台组件的 pod 之后, 我注意到在同一节点上运行的 pod 无法通过服务相互访问。

例如,我的 presto 协调器必须访问 hive 元存储。 让我们看看我的命名空间中的服务:

kubectl get svc -n ai-developer
NAME                                              TYPE           CLUSTER-IP      EXTERNAL-IP      PORT(S)                      AGE
metastore                                 ClusterIP      10.233.12.66    <none>           9083/TCP                     4h53m

Hive Metastore 服务称为metastore,我的 presto 协调器必须通过它访问 hive Metastore pod。 让我们看看我的命名空间中的以下 pod:

kubectl get po -n ai-developer -o wide
NAME                                          READY   STATUS      RESTARTS   AGE     IP             NODE       NOMINATED NODE   READINESS GATES
metastore-5544f95b6b-cqmkx                    1/1     Running     0          9h      10.233.69.20   minion-3   <none>           <none>
presto-coordinator-796c4c7bcd-7lngs           1/1     Running     0          5h32m   10.233.69.29   minion-3   <none>           <none>
presto-worker-0                               1/1     Running     0          5h32m   10.233.67.52   minion-1   <none>           <none>
presto-worker-1                               1/1     Running     0          5h32m   10.233.70.24   minion-4   <none>           <none>
presto-worker-2                               1/1     Running     0          5h31m   10.233.68.24   minion-2   <none>           <none>
presto-worker-3                               1/1     Running     0          5h31m   10.233.71.27   minion-0   <none>           <none>

查看 hive Metastore pod metastore-5544f95b6b-cqmkx ,它在节点 minion-3 上运行,presto 协调器 pod presto-coordinator-796c4c7bcd-7lngs 也在其上运行。

我已将 thrift://metastore:9083 的配置单元元存储 url 配置为 presto 协调器中配置单元目录的配置单元属性。 当 presto pod 在运行 hive metastore pod 的同一节点上运行时,它们无法访问我的 hive metastore,但是在 hive metastore 未运行的其他节点上运行的 pod 可以通过service 很好地访问 hive metastore .

我只提到了一个例子,但我现在还经历过其他几个类似这个例子的案例。

kubenet 作为网络插件安装在我的 kubernetes 集群中,在 azure 上安装了 kubespray:

/usr/local/bin/kubelet --logtostderr=true --v=2 --node-ip=10.240.0.4 --hostname-override=minion-3 --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --config=/etc/kubernetes/kubelet-config.yaml --kubeconfig=/etc/kubernetes/kubelet.conf --pod-infra-container-image=k8s.gcr.io/pause:3.1 --runtime-cgroups=/systemd/system.slice --hairpin-mode=promiscuous-bridge --network-plugin=kubenet --cloud-provider=azure --cloud-config=/etc/kubernetes/cloud_config

有什么想法吗?

【问题讨论】:

    标签: kubernetes


    【解决方案1】:

    请检查 iptables Chain FORWARD 默认策略是否为 ACCEPT 。 在我的情况下,将 Forward 链默认策略从 drop 设置为 accept,节点之间的通信效果很好。

    【讨论】:

    • 谢谢,保罗。我已经检查了我节点上的 iptables,Chain FORWARD 是接受的。我不在同一个节点上运行的pods也可以通过service很好地相互连接,但是在同一个节点上运行的pods却不通过service
    【解决方案2】:

    您可以通过使用 k8s 为您解析服务 ips 提供的完全限定名称来解决此问题,如 k8s docsenter link description here 中所述。

    在您的情况下,这可能意味着将您的thrift://metastore:9083 属性更改为thrift://metastore.ai-developer.svc.cluster.local(当然,假设您的集群域配置为cluster.local

    【讨论】:

    • 感谢您的回答。抱歉,我今天稍晚更新了我的问题。正如其中所提到的,在 hive metastore pod 未运行的另一个节点上运行的 pod 可以很好地访问 hive metastore。我也按照您的建议使用完全限定域名进行了测试,但它不适用于同一个节点。
    【解决方案3】:

    我把kube代理模式的ipvs改成iptables后,就可以正常使用了!

    【讨论】:

      猜你喜欢
      • 2019-01-18
      • 2020-01-01
      • 2018-04-11
      • 1970-01-01
      • 2023-03-24
      • 2020-05-19
      • 2019-07-01
      • 2021-07-26
      • 2018-12-11
      相关资源
      最近更新 更多