标签:
关于 kubernetes master 多节点以及高可用,网上的方法多采取 Active-Standby 方式,即:
通过 pacemaker 等软件使得某种 master 服务(apiserver,scheduler,controller-manager)同一时间只运行一个实例。具体来说,如果有多台master node,上面都安装了scheduler,controller-manager, apiserver:
这种方法的可靠性有待探讨,至少我出现过这样的问题:一旦因pacemaker出现问题或者管理员误操作,在多个节点上同时启动了scheduler或者controller-manager,就会造成系统故障。
实际上,参考kubernetes最新文档,官方有相关的提示:
Master elected components
So far we have set up state storage, and we have set up the API server, but we haven’t run anything that actually modifies cluster state, such as the controller manager and scheduler. To achieve this reliably, we only want to have one actor modifying state at a time, but we want replicated instances of these actors, in case a machine dies. To achieve this, we are going to use a lease-lock in the API to perform master election. We will use the --leader-elect
flag for each scheduler and controller-manager, using a lease in the API will ensure that only 1 instance of the scheduler and controller-manager are running at once.
也就是说,controller-manager和scheduler 只要加上 --leader-elect=true 参数就可以同时启动,系统会自动选举leader。而apiserver本来就可以多节点同时运行,只要它们连接同一个etcd cluster 就可以了。
按照上面的思路,master ha 架构可以如下设计:
注:
1. 首先设置etcd cluster
关于etcd的cluster设置方法,网上有成熟的文档可以参考;
2. 各个master 节点的apiserver同时启动,指向相同的 etcd cluster
3. apiserver 服务设置 VIP
建议通过keepalived+lvs 或者 haproxy设置,支持负载均衡;
4. 各个master 节点的controller-manager 和 scheduler 加 --leader-elect=true 参数同时启动
经过上面的设置,所有master节点上的相关服务都是 Active 状态,如果有一个节点或者一个服务挂掉都不影响整个集群的运行。
[经验交流] Active-Active 方式设置 kubernetes master 多节点高可用
标签:
原文地址:http://www.cnblogs.com/hahp/p/5803694.html