In this blog post, we will discuss Static Pods in Kubernetes and how they differ from regular pods. This feature allows you to run pods on specific nodes without the need for a full Kubernetes cluster.
Static Pods are a type of Kubernetes Pod that is managed directly by the kubelet on a specific node, without the involvement of the Kubernetes API server. They are used in scenarios where you need to run a pod on a particular node, and the pod should not be managed by the Kubernetes control plane.
To create a Static Pod, you need to add a YAML file to a specific directory on the node that the kubelet watches. The kubelet will then automatically create the pod based on the YAML file.
apiVersion: v1
kind: Pod
metadata:
name: my-static-pod
spec:
containers:
- name: my-container
image: my-image
By default, the kubelet watches the /etc/kubernetes/manifests/ directory for Static Pod manifests. You can change this directory using the --pod-manifest-path flag when starting the kubelet.
| Feature | Static Pods | Regular Pods |
|---|---|---|
| Deployment | Directly on the node | Via the API server |
| Management | Managed by the kubelet | Managed by the Kubernetes control plane |
| Configuration file location | Node's filesystem | Kubernetes API |
| Node failure impact | Pod is not rescheduled | Automatically rescheduled |
| Scaling | Manual scaling | Horizontal Pod Autoscaler (HPA) |
| Rolling updates and rollbacks | Not natively supported | Supported via Deployments |
| Node-specific configuration | Tied to specific nodes | Independent of nodes |
| Use cases | System daemons, cluster maintenance | General application workloads |
In conclusion, Static Pods offer a way to run pods on specific nodes without involving the Kubernetes control plane. They are useful in situations where you need more direct control over the pods running on a particular node, such as running system services or managing node-local resources.