锐单电子商城 , 一站式电子元器件采购平台!
  • 电话:400-990-0325

关于kubernetes两节点和三节点的区别测试

时间:2023-09-13 07:07:02 m44电容柜用m44r电阻器

根据K8s三节点是一个稳定的集群。以前使用过kubeadm构建了两个节点的环境,在测试高可用性时确实发现了问题,一个节点崩溃,整个群体崩溃。
实验的目的是验证三节点的高可用性
忽略施工过程,看实验结果
对比两个场景
场景1,双节点
koonsuenmaster03(初始化节点):192.168.8.13
koonsuenmaster02(添加节点): 192.168.8.12

关闭节点03

[root@koonsuenmaster02 ~]# kubectl get nodes NAME               STATUS   ROLES                  AGE     VERSION koonsuenmaster02   Ready    control-plane,master   7h      v1.20.6 koonsuenmaster03   Ready    control-plane,master   32h     v1.20.6 [root@koonsuenmaster02 ~]# kubectl get nodes Unable to connect to the server: net/http: TLS handshake timeout 

集群崩溃,关闭节点02,效果相同,kubectl命令不能返回

场景2,三节点
koonsuenmaster03(初始化节点):192.168.8.13
koonsuenmaster02(添加节点): 192.168.8.12
koonsuenmaster04(添加节点):192.168.8.14

关闭03节点前后情况:

[root@koonsuenmaster02 ~]# kubectl get nodes NAME               STATUS   ROLES                  AGE     VERSION koonsuenmaster02   Ready    control-plane,master   7h1m    v1.20.6 koonsuenmaster03   Ready    control-plane,master   32h     v1.20.6 koonsuenmaster04   Ready    control-plane,master   5m12s   v1.20.6 [root@koonsuenmaster02 ~]# kubectl get nodes NAME               STATUS     ROLES                  AGE     VERSION koonsuenmaster02   Ready      control-plane,master   7h1m    v1.20.6 koonsuenmaster03   NotReady   control-plane,master   32h     v1.20.6 koonsuenmaster04   Ready      control-plane,master   5m14s   v1.20.6  

可见03节点已经是了NotReady状态,群集仍然可用,kubectl get nodes以下是04节点03节点退出的瞬间:

[root@koonsuenmaster04 ~]# kubectl get nodes NAME               STATUS   ROLES                  AGE     VERSION koonsuenmaster02   Ready    control-plane,master   7h      v1.20.6 koonsuenmaster03   Ready    control-plane,master   32h     v1.20.6 koonsuenmaster04   Ready    control-plane,master   4m44s   v1.20.6 [root@koonsuenmaster04 ~]# kubectl get nodes Unable to connect to the server: net/http: TLS handshake timeout [root@koonsuenmaster04 ~]# kubectl get nodes NAME               STATUS   ROLES                  AGE    VERSION koonsuenmaster02   Ready    control-plane,master   7h     v1.20.6 koonsuenmaster03   Ready    control-plane,master   32h    v1.20.6 koonsuenmaster04   Ready    control-plane,master   5m2s   v1.20.6  

可见瞬间出现kubectl如果命令没有返回,如果是双节点,它将永远存在timeout
或者其他提示,集群不可用。

三节点以上K8s生产环境解决方案。
PS:
K8s构建经验:
用虚拟机加控制平面节点非常方便,克隆机,kubeadm reset,看提示操作。
关键步骤是传递证书,安装后一键三联,以及后续网络插件的安装。
继续学习二进制安装的机会。

锐单商城拥有海量元器件数据手册IC替代型号,打造电子元器件IC百科大全!

相关文章