current position:Home>46 k8s cluster high availability

46 k8s cluster high availability

2022-01-27 02:37:48 InfoQ

Kubernetes Self healing ability
, It tracks when a work node fails , The control plane can transfer the data on the offline node Pod Objects are rearranged to other available work nodes to run , therefore , More work nodes also mean better fault tolerance , It makes the Kubernetes More flexible degrees of freedom when implementing work node failover . and
When the administrator detects that the cluster is overloaded or cannot accommodate more Pod Object time , Or manually add new nodes to the cluster , Or for... In the cloud computing environment Kubernetes Enable cluster-autoscaler To support automatic scaling of cluster node size
.

Generally speaking , High availability control plane
Need at least 3 individual Master Nodes to withstand the most 1 individual Master Loss of nodes
, In order to ensure the waiting state Master Keep more than half of the nodes , To meet the legal number of votes at the node election .

etcd be based on Go Language development ,
Internal use Raft The protocol is used as a consensus algorithm for distributed cooperation
, The reliability of data is improved by synchronously storing data on multiple independent service instances , Avoid data loss caused by single point of failure .
Raft The agreement was elected leader Nodes achieve data consistency
, from leader The node is responsible for all write requests and synchronizes them to all nodes in the cluster , More than half follower The node will be persistent stored after confirmation . This mechanism, which requires more than half of the nodes to vote, requires that the number of clusters should preferably be an odd number of nodes ,
The recommended quantity is 3 individual 、5 Or 7 individual . establish etcd Cluster has 3 Ways of planting
.

Static cluster
: Plan in advance and provide fixed data for all nodes IP Address to form a cluster , It is only suitable for nodes that can be assigned static IP Address network environment , The advantage is that it doesn't rely on any external services .

be based on etcd Discover services and build clusters
: Through a pre-existing etcd The cluster performs service discovery to form a new cluster , Support the dynamic construction of clusters , It relies on an existing available etcd service .

be based on DNS Build a cluster of service resource records
: By means of DNS Create a message for each node under a domain name on the service SRV Record , Then, service discovery based on this domain name is carried out to dynamically form a new cluster , It depends on DNS Services and well managed resource records in advance .

As a general rule , about etcd For distributed storage clusters ,
3 The node cluster can fault-tolerant one node ,5 A node cluster can tolerate two nodes ,7 Node clusters are fault tolerant 3 Nodes
, And so on ,
But usually more than 7 A cluster size of nodes is unnecessary
, And it will also have a negative impact on the system performance .

Stacked etcd The cluster topology aligns the control planes on the same nodes with each other etcd Members are coupled together , Each control plane node runs a
etcd、kube-apiserver、kube-scheduler and kube-controller-manager example
. And then kubeadm The deployed class is in the control plane , various kube-apiserver The instance is only associated with the instance on the local node etcd Member communication , And each
kube-scheduler and kube-controller-manager It is also only related to... On the local node kube-apiserver signal communication
.


copyright notice
author[InfoQ],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/01/202201270237454991.html

Random recommended