Kubernetes Static Pods
Static Pods bypass this entire “brain.” They are pods that are managed directly by the Kubelet daemon on a specific node, without the API Server observing or managing the initial configuration.
How Do They Work?
The mechanism relies entirely on the filesystem of the node.
- The Manifest Folder: The Kubelet configuration file (
/var/lib/kubelet/config.yaml) defines a specific directory path, usuallystaticPodPath. By default, this is often set to:/etc/kubernetes/manifests - Creation: If you place a valid Pod YAML file into this folder, the Kubelet daemon (which scans this folder periodically) automatically creates and starts the Pod.
- Deletion: To delete the Pod, you simply remove the file from that folder. Kubelet notices the file is gone and terminates the Pod.
- Mirror Pods: Even though the Kubelet creates the pod locally, it tries to create a Mirror Pod on the Kubernetes API Server.
- Purpose: This allows you to see the static pod when you run
kubectl get pods. - Limitation: These mirror pods are read-only. You cannot edit or delete them via the API Server (e.g.,
kubectl delete podwill fail or simply leave the pod running because the source file still exists on the node).
- Purpose: This allows you to see the static pod when you run
Why Do We Need Them?
The primary use case for Static Pods is Bootstrapping the Control Plane.
This helps solve the “Chicken and Egg” problem: How do you run the Kubernetes Control Plane components (which are Pods) if Kubernetes isn’t running yet?
You use Static Pods to start the essential components on the Master Node:
- kube-apiserver
- etcd
- kube-controller-manager
- kube-scheduler
Since these are defined as static manifests on the Master Node’s disk, the Kubelet can start them up immediately when the machine boots, bringing the cluster to life.
Limitations
- No Scheduling: You cannot ask a Static Pod to “move” to another node. You have to manually move the file.
- Limited Health Checks: While Kubelet checks liveness, integration with complex cloud-native health reporting is limited compared to standard deployments.
- ConfigMap/Secret Dependency: Static Pods running the Control Plane cannot mount ConfigMaps or Secrets from the API Server (because the API server might not be ready!). They usually rely on local files for configuration.
Static Pods and Kubelet Config (staticPodPath)