Kubernetes architecture (control plane and nodes) - Time & Space Complexity
We want to understand how the work done by Kubernetes grows as we add more nodes and workloads.
How does the system handle more tasks and keep everything running smoothly?
Analyze the time complexity of the control plane managing nodes.
apiVersion: v1
kind: Pod
metadata:
name: example-pod
spec:
containers:
- name: example-container
image: nginx
nodeSelector:
disktype: ssd
This snippet schedules a pod to a node with a specific label, showing how the control plane selects nodes.
Look at what repeats when scheduling pods.
- Primary operation: The scheduler checks all nodes to find a match for the pod's requirements.
- How many times: It does this for each pod and each node available.
As the number of nodes or pods grows, the scheduler's work grows too.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 nodes, 10 pods | ~100 checks (each pod checks nodes) |
| 100 nodes, 100 pods | ~10,000 checks |
| 1000 nodes, 1000 pods | ~1,000,000 checks |
Pattern observation: The work grows quickly as both pods and nodes increase.
Time Complexity: O(p × n)
This means the scheduler's work grows proportionally to the number of pods times the number of nodes.
[X] Wrong: "The scheduler only checks one node per pod, so it's always fast."
[OK] Correct: The scheduler must consider all nodes to find the best fit, so work grows with nodes and pods.
Understanding how Kubernetes scales helps you explain system behavior and design choices clearly.
"What if the scheduler used caching to remember node states? How would that affect the time complexity?"
Practice
Solution
Step 1: Understand Kubernetes architecture roles
The control plane manages the cluster and makes decisions about scheduling and managing workloads.Step 2: Identify the component that schedules workloads
The control plane includes the scheduler which decides what runs and where.Final Answer:
Control plane -> Option DQuick Check:
Control plane = workload decision maker [OK]
- Confusing nodes with control plane
- Thinking containers decide scheduling
- Mixing pods with control plane
Solution
Step 1: List control plane components
Control plane includes etcd, kube-apiserver, kube-controller-manager, and kube-scheduler.Step 2: Identify which option is part of control plane
etcd stores cluster data and is part of the control plane.Final Answer:
etcd -> Option AQuick Check:
etcd = control plane data store [OK]
- Confusing kubelet as control plane
- Thinking kube-proxy is control plane
- Mixing container runtime with control plane
Solution
Step 1: Identify node components
Nodes run components like kubelet and kube-proxy to manage containers and networking.Step 2: Determine which component manages container lifecycle on nodes
kubelet runs on each node and ensures containers are running as expected.Final Answer:
kubelet -> Option AQuick Check:
kubelet = node container manager [OK]
- Confusing kube-apiserver as node component
- Thinking scheduler runs on nodes
- Mixing etcd with node components
Solution
Step 1: Understand pod startup process
Pods are started and managed on nodes by the kubelet component.Step 2: Identify component to check for node pod issues
Since pods fail to start on a node, kubelet logs and status should be checked first.Final Answer:
kubelet -> Option BQuick Check:
kubelet manages pods on nodes [OK]
- Checking scheduler instead of kubelet
- Looking at etcd for node pod errors
- Confusing apiserver with node issues
Solution
Step 1: Understand control plane failure impact
The control plane manages scheduling and cluster state but nodes run pods independently.Step 2: Analyze pod behavior when control plane is down
Existing pods keep running on nodes, but no new pods can be scheduled without control plane.Final Answer:
Existing pods continue running but no new scheduling occurs -> Option CQuick Check:
Control plane down = no new scheduling, pods run [OK]
- Thinking pods stop immediately
- Assuming nodes become control planes
- Believing new pods schedule without control plane
Ready to prove it?
Pass the test and this pattern moves unknown
