Kubelet can independently manage pods on worker nodes without relying on other K8s components. Kubelet can be configured to look for k8s manifest files in a directory on the node. It can then automatically create, update and manage pods on the node based on the manifests files present in the directory. These pods are called static pods.

Untitled

If any static pod crashes, Kubelet will attempt to restart it. To delete a static pod, delete its manifest file from the directory.

To view the static pods running on a worker node, run sudo crictl ps on that node. This is because we don’t have the kubectl utility as we don’t have the kube-api server available on the node.

<aside> 💡 Only pods can be created in a static manner. Other K8s objects like ReplicaSets and Deployments depend on additional k8s components.

</aside>

Configure pod manifest path

To configure the pod manifest path in the kubelet service, use the below highlighted configuration in the kubelet service. This can be viewed for a running kubelet service by running ps -aux | grep kubelet.

Untitled

Another option is to refer staticPodPath from the kubelet config file (--config option) in the kubelet service.

Untitled

Static Pods in a Cluster

Even if the node is a part of the cluster, we can create static pods by configuring the manifest directory and adding pod definition files in it. When a static pod is created in a node which is a part of the cluster, a mirror (read-only) object is also created in the KubeAPI server. This way, the KubeAPI Server is aware of the static pods created in the cluster.

Static pods running on a node are handled exclusively by the Kubelet running on that node. Kube Scheduler has no control over these pods.

Static pods that are a part of the cluster can be viewed using the k get pods command. They have the node name appended to their name.

Setting up the control plane using static pods

Since static pods don’t depend on the control plane, we can use them to deploy the components of the control plane as pods on a node.

Let’s say we are setting up a multi-master cluster. Start by installing the kubelet service on all of the nodes. Then, place the K8s manifests of the remaining control plane components in the staticPodPath in every node. Kubelet will bring up all the pods and if any of them fails, it will be restarted by Kubelet automatically.

Untitled

<aside> 💡 KubeAdm uses this approach to set up the control plane.

</aside>