Static Pods


Static pods are a special kind of pod that is managed directly by the kubelet on a node, rather than by the Kubernetes API server.

🔧 Why Static Pods?

Imagine a scenario where there is no master node — no API server, no etcd, no scheduler.
How would you run a pod on your node?

The answer: static pods.

📂 How Static Pods Work

You can create a pod manifest file in the node’s local directory at:

/etc/kubernetes/manifests

The kubelet watches this directory. When a manifest is added:
• It creates the pod as defined.
• It ensures the pod remains running.
• If the pod crashes or is deleted, kubelet will automatically restart it.

Note:
• You cannot scale static pods using kubectl scale.
• Static pods are not rescheduled to another node if the current node fails.

🔍 Visibility in Kubernetes

Although static pods are not managed by the API server, the kubelet registers them as mirror pods.
This means you can still view them using:

kubectl get pods -A

However, you cannot manage or modify them through the API server.

📌 When Are Static Pods Used?

Static pods are commonly used to run critical control plane components on master nodes, such as:
• kube-apiserver
• kube-controller-manager
• etcd

✅ Example: Running a Static Pod in Minikube
1. SSH into your Minikube node:

minikube ssh

2. Create a manifest file:

sudo vi /etc/kubernetes/manifests/static-nginx.yaml

3. Paste the following:

apiVersion: v1
 kind: Pod
 metadata:
 name: static-nginx
 labels:
 app: nginx
 spec:
 containers:
 - name: nginx
 image: nginx:latest
 ports:
 - containerPort: 80

4. On your host terminal, verify:

kubectl get pods -A

You will see the static-nginx pod listed under the default namespace.

🧹 Cleanup

To remove the static pod:

sudo rm /etc/kubernetes/manifests/static-nginx.yaml

The kubelet will automatically stop and clean up the pod.


Leave a Reply

Your email address will not be published. Required fields are marked *