Kuberenetes 节点到节点通信未按预期工作

Kuberenetes 节点到节点通信未按预期工作

大家好

我的 Kubernetes 集群确实有问题

规格

NAME                 STATUS   ROLES    AGE   VERSION   INTERNAL-IP     EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION     CONTAINER-RUNTIME
k8s-w02-prod   Ready    <none>   40d   v1.19.2   192.168.25.20   <none>        Ubuntu 20.04.1 LTS   5.4.0-54-generic   docker://19.3.8
k8s-m01-prod   Ready    master   40d   v1.19.2   10.60.17.15    <none>        Ubuntu 20.04.1 LTS   5.4.0-58-generic   docker://19.3.8
k8s-m02-prod   Ready    master   40d   v1.19.2   10.60.17.16    <none>        Ubuntu 20.04.1 LTS   5.4.0-54-generic   docker://19.3.8
k8s-m03-prod   Ready    master   40d   v1.19.2   10.60.17.17    <none>        Ubuntu 20.04.1 LTS   5.4.0-54-generic   docker://19.3.8
k8s-w01-prod   Ready    <none>   40d   v1.19.2   192.168.29.20    <none>        Ubuntu 20.04.1 LTS   5.4.0-54-generic   docker://19.3.8

集群网络插件 使用 Calico

Pod:网络:podSubnet:10.65.0.0/16

Calico process is running.

IPv4 BGP status
+---------------+-------------------+-------+------------+-------------+
| PEER ADDRESS  |     PEER TYPE     | STATE |   SINCE    |    INFO     |
+---------------+-------------------+-------+------------+-------------+
| 192.168.25.20 | node-to-node mesh | up    | 23:37:55   | Established |
| 10.60.11.156  | node-to-node mesh | up    | 2021-01-04 | Established |
| 10.60.11.157  | node-to-node mesh | up    | 2021-01-04 | Established |
| 192.168.29.20 | node-to-node mesh | up    | 2021-01-04 | Established |
+---------------+-------------------+-------+------------+-------------+

IPv6 BGP status
No IPv6 peers found.

它使用节点到节点网格

问题

当我运行简单应用程序时例如:ArgoCD

argo-cd-argocd-application-controller-74dd8b79f5-vldhb   1/1     Running   0          14h   10.65.102.48   k8s-w02-prod   <none>           <none>
argo-cd-argocd-dex-server-5c656d6c6c-shb69               1/1     Running   0          14h   10.65.102.52   k8s-w02-prod   <none>           <none>
argo-cd-argocd-redis-9757589c5-6w2p6                     1/1     Running   0          14h   10.65.102.60   k8s-w02-prod   <none>           <none>
argo-cd-argocd-repo-server-774c6856f9-vgmq8              1/1     Running   0          14h   10.65.102.4    k8s-w02-prod   <none>           <none>
argo-cd-argocd-server-669fc6db5c-x5w4k                   1/1     Running   0          13h   10.65.72.159   k8s-w01-prod   <none>           <none>

问)我无法访问 ArgoCD Web UI,因为我看到 Pod 正在运行

  • Worker01:k8s-w01-prod 192.168.25.20
ip route | grep tun

10.65.69.192/26 via 10.60.17.17 dev tunl0 proto bird onlink 
10.65.102.0/26 via 192.168.25.20 dev tunl0 proto bird onlink 
10.65.187.64/26 via 10.60.17.15 dev tunl0 proto bird onlink 
10.65.233.192/26 via 10.60.17.16 dev tunl0 proto bird onlink 


worker02:k8s-w02-prod 192.168.29.20

10.65.69.192/26 via 10.60.17.17 dev tunl0 proto bird onlink 
10.65.72.128/26 via 192.168.29.20 dev tunl0 proto bird onlink 
10.65.187.64/26 via 10.60.17.15 dev tunl0 proto bird onlink 
10.65.233.192/26 via 10.60.17.16 dev tunl0 proto bird onlink 

在不同的子网上运行

两边 Ping 都完全正常

当我使用节点选择器标签在选定节点(即 worker01 或 worker02)上运行 pod 时,问题就解决了。

问)我如何路由流量以便应用程序 ArgoCD WebUI 正常工作而不会出现任何节点间通信问题(Pod 可以在任何节点上运行并且可以相互通信)

问)在 calico 上使用 BGP 是个好主意吗?没有节点到节点的网格

https://docs.projectcalico.org/networking/bgp

请告诉我如何解决这个问题

答案1

我找到了使用 nodeAffinity 解决此问题的解决方法

       affinity:   
         nodeAffinity:
           preferredDuringSchedulingIgnoredDuringExecution:
           - weight: 1
             preference:
               matchExpressions:
               - key: "kubernetes.io/hostname"
                 operator: In
                 values:
                 - k8s-w01-prod

但我这边仍然存在问题

相关内容