Kubernetes: Static Pods

Claire Lee
4 min readMar 11, 2023

--

Static pods in Kubernetes are created and managed directly by the kubelet service on a node, without the need for a Kubernetes API server. The staticPodPath configuration setting specifies the directory path where the kubelet service should look for static pod manifests. Although static pods cannot be managed from the Kubernetes API server, they can be retrieved using the kubectl get pods command. To modify a static pod, we must edit the pod definition file on the node where the pod is running.

Kubernetes: Static Pods

Static Pods

In Kubernetes, a static pod is a pod that is managed directly by the kubelet on a specific node, without going through the Kubernetes API server. Therefore, you cannot update the configuration of a static Pod using kubectl, and you cannot use features like rolling updates or resource quotas with static Pods.

To manage static pods, you need to create, update, or delete the corresponding pod configuration file from a local directory on the node where the pod is running. The kubelet monitors this directory and automatically starts and stops the Pods based on changes to the manifest files.

Static Pods are useful for running critical system components directly on a node, you can create a static Pod for that component to ensure it is always running on that node.

Analogy

In a restaurant, there is a special dish that is always in high demand and must be available at all times. To ensure that this dish is always available, you have a dedicated chef who prepares this dish at a specific kitchen station without going through the standard ordering process. This chef knows exactly how to prepare the dish, and is responsible for ensuring that there is always enough of the dish available for customers.

In the context of Kubernetes, the dedicated chef is like the kubelet on a node, and the special dish is like a static pod. The kubelet is responsible for ensuring that the static pod is always running on the node, just like the dedicated chef is responsible for ensuring that the special dish is always available at their kitchen station.

Retrieve static Pods using “kubectl get pods” command?

We can retrieve static Pods using kubectl get pods command because the kubelet automatically attempts to generate a mirror Pod of each static Pod on the Kubernetes API server. The Pod names that are displayed in the output of the command will be modified to include the node’s hostname as a suffix, which will be preceded by a hyphen.

$ kubectl get pods -o wide
NAME .... NODE ....
<static_pod_name>-<node_hostname> <node_hostname>

However, we are not able to edit or delete the static Pods using the Kubernetes API server, as they are managed directly by the kubelet on a specific node. To modify a static pod, we must edit the pod definition file on the node where the pod is running.

staticPodPath

In Kubernetes, a staticPodPath is a configuration setting that specifies the directory path where the kubelet service running on a node should look for static pod manifests.

$ cat /var/lib/kubelet/<configuration>.yaml

staticPodPath: <path/to/static/pod>
staticPodPath

/var/lib/kubelet: a directory on each Kubernetes node that is used by the kubelet component to store various data and configurations related to the node and the Pods running on it.

Create, Edit and Delete Static Pods

  • Create a static Pod
    Add pod definition file to staticPodPath
$ kubectl run <static_pod_name> --image=<image> --dry-run=client -o yaml > 
<staticPodPath>/<static_pod_file_name>.yaml
  • Edit a static Pod
    Edit the pod definition file
$ vi <staticPodPath>/<static_pod_file_name>.yaml
  • Delete a static Pod
    Remove the pod definition file from staticPodPath
$ rm <staticPodPath>/<static_pod_file_name>.yaml
create, edit and delete static Pods

No Static Deployment, Static ReplicaSet, or Static Service Objects

Static Pods are the only type of “static” object in Kubernetes. The kubelet works at the Pod level because it is responsible for managing the lifecycle of each Pod running on the node.

Static Pods vs. DemonSets

Static Pods and DaemonSets are both Kubernetes objects that are used to manage pods, but they serve different purposes.

static Pods vs. DaemonSets

--

--

Claire Lee
Claire Lee

No responses yet