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

分享于 

4分钟阅读

互联网

  繁體

问题:

Kubernete集群有问题

集群


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.



它使用节点到节点网格

问题

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


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 Bcoz,因为我看到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在两端完全正常


答案1:

使用nodeAffinity来处理这个问题


 affinity: 


 nodeAffinity:


 preferredDuringSchedulingIgnoredDuringExecution:


 - weight: 1


 preference:


 matchExpressions:


 - key: "kubernetes.io/hostname"


 operator: In


 values:


 - k8s-w01-prod





相关文章