How does Quorum work in etcd based on Raft algorithm, and why should always use an odd number of nodes in production environments?
etcd is based on the Raft Consensus algorithm, which requires an absolute majority (N/2 + 1) to confirm any write operation and choose a leader. Using an odd number (3 or 5) provides the same fault tolerance as a higher even number (3 nodes are just as tolerant as 4 nodes), but avoids additional resource consumption and the risk of a split-brain.
Detailed Technical Explanation & PracticeExpand DetailsCollapse Details
The formula for calculating quorum in Raft is:
Quorum = floor(N / 2) + 1| Number of nodes (N) | Quorum | Number of faults allowed |
|---|---|---|
| 1 | 1 | 0 |
| 3 | 2 | 1 |
| 4 | 3 | 1 (useless compared to 3) |
| 5 | 3 | 2 |
| 7 | 4 | 3 |
If the block splits due to a network outage:
- The group that owns 3 nodes out of 5 meets the quorum and continues the read-write service.
- A group that has two nodes loses quorum and rejects all modification operations to prevent split-brain memory and data collision.
If the entire cluster loses quorum, kube-apiserver stops accepting any new operations or updates, but the Pods running on the Worker Nodes continue to serve existing traffic until the quorum returns.
- The belief is that increasing the number of nodes to large numbers (such as 9 or 11) increases write performance, while the reality is that increasing the number of nodes increases the time for confirming transactions across the network.
- Install etcd nodes on slow disks; etcd requires very low synchronous (fsync) write speeds without delay.
- If the network goes down and a cluster of 5 nodes is divided into two groups (3 nodes and 2 nodes), which group will continue to accept writes and why?
- How does the loss of Quorum affect the operation of existing Pods in Worker Nodes?
Explain the stages that Kube-Scheduler goes through to schedule a new work pod on an appropriate node.
Kube-Scheduler goes through two main phases: a Filtering / Predicates phase to exclude ineligible nodes, and then a Scoring / Priorities phase to give the remaining nodes scores and choose the node with the highest score.
Detailed Technical Explanation & PracticeExpand DetailsCollapse Details
Scheduling steps:
- Filtering (Predicates):
- Checks resource constraints: Does the node have enough
requests.cpuandrequests.memory? - Checks compatibility constraints:
nodeSelectorandnodeAffinity. - Checks isolation restrictions:
Taints and Tolerations, and port occupancyPodFitsHostPorts.
- Checks resource constraints: Does the node have enough
- Scoring (Priorities):
- Eligible nodes are given scores from 0 to 100 according to their distribution strategies (such as preferring to deploy pods over different geographic regions
TopologySpreadConstraints, or resource consumption strategiesNodeResourcesBalancedAllocation).
- Eligible nodes are given scores from 0 to 100 according to their distribution strategies (such as preferring to deploy pods over different geographic regions
- Binding:
- The Scheduler writes the name of the winning node into the
spec.nodeNamefield of the object in etcd via the API Server.
- The Scheduler writes the name of the winning node into the
- The belief is that Kube-Scheduler is running the containers; Scheduler just binds the Pod to the node name via the Binding API, while the Kubelet on that node calls the CRI and runs the containers.
- Ignore Taints and Tolerations and NodeAffinity while calculating resource filtering and scheduling.
- What happens if several nodes in the scoring phase tie for the highest score?
- What does Pod Preemption do when no node can accommodate the required Pod resources?
What are the responsibilities of Kubelet on the Worker Node and how does it communicate with the Container Runtime Interface (CRI)?
Kubelet is an Agent that runs on each Worker Node; monitors the PodSpecs assigned to its node, requests the Container Run Interface (CRI such as containerd) to start or stop containers, installs volumes, checks the health of containers via Probes, and reports the status of the node and pods to the API Server.
Detailed Technical Explanation & PracticeExpand DetailsCollapse Details
The Kubelet communicates with the Container Runtime via CRI (Container Runtime Interface) using the gRPC protocol over a Unix Domain Socket (eg /run/containerd/containerd.sock):
- Pod Lifecycle Management: When a new PodSpec arrives, it creates an isolation space, then calls CRI to create the sandbox and then launch the child containers.
- Volume Mounting: Prepares volume mount points (Persistent Volumes, Secrets, and ConfigMaps) before starting the container.
- Health Checking: Performs the
livenessProbe,readinessProbeandstartupProbechecks. - Status Reporting: Periodically sends Heartbeats to
kube-apiserver(via Lease objects) to confirm that the node is still inReadystate.
- The belief is that Kubelet runs inside a container like the rest of the Kubernetes components; in most distributions Kubelet runs as a native system service (systemd service) directly on the host node's operating system.
- Belief that Kubelet is talking to Docker directly; Dockershim has been dropped and Kubelet is talking to CRI via gRPC Unix Socket.
- What is the difference between gRPC RuntimeService and ImageService in the CRI interface?
- What are Static Pods and how does Kubelet manage them locally without interference from the Kube-Scheduler?