Static Pods: Kubernetes

Sourin
2 min readDec 15, 2023

Kubernetes, an orchestration platform, manages various components with its control plane. Control plane includes components like Kube-Api-Server, Kube-Scheduler, Kube-Controller Manager, Kubelet, Kube-Proxy, and the ETCD Database. There's a type of pod called a "Static Pod" that operates outside this traditional realm.

What Are Static Pods?🚀

Static pods are a unique type of pods in Kubernetes. Unlike regular pods, they aren’t controlled by the Kubernetes control plane but are managed directly by the kubelet on specific nodes. They're defined in configuration files and run on a node without going through the Kubernetes API server or the kube-scheduler.

Identifying a Static Pod 🕵️‍♂️

A simple way to spot a static pod is by examining its naming convention; a static pod includes the node name along with its pod name. You can also inspect the kubelet configuration file (/var/lib/kubelet/config.yaml) to find the staticPodPath that specifies the directory housing these static pod manifests, commonly found at /etc/kubernetes/manifests.

Use Cases and Benefits 🧭

Static pods are valuable when specific pods need to run directly on a node, bypassing the control plane. They’re often employed for system-level services or to bootstrap critical Kubernetes control plane components like the kubelet itself.

Creating and Managing Static Pods 🛠️

Creating a static pod is simple. You can define it in a manifest file placed in the static pod directory (/etc/kubernetes/manifests/) or create it using kubectl commands.

To create a static pod named static-busybox with the busybox image and a sleep 1000 command:

apiVersion: v1
kind: Pod
metadata:
name: static-busybox
spec:
containers:
- name: busybox
image: busybox
args:
- sleep
- "1000"

Alternatively, use the command:

kubectl run — restart=Never — image=busybox static-busybox — dry-run=client -o yaml — command — sleep 1000 > /etc/kubernetes/manifests/static-busybox.yaml

Managing Static Pods 🗑️

Deleting a running static pod involves locating the directory specified by staticPodPath on the node and deleting the corresponding YAML file.

Deleting a Static Pod:

  1. SSH into the node: ssh node-name or ssh internal-IP-address
  2. Find the directory of staticPodPath: cat /var/lib/kubelet/config.yaml
  3. Delete the YAML file.

Conclusion 🎉

Static pods provide an alternative method for running critical services directly on nodes without being managed by the Kubernetes control plane. Understanding them and their management process can be beneficial for specific use cases and scenarios within your Kubernetes setup.

--

--