What are the Static Pods on Kubernetes?

Let's dive into understanding static pods. To begin, let's explore how pods are scheduled on a node.

Pod scheduling involves three main components: Kube-apiserver, kube-scheduler, and kubelet. The kube-scheduler executes functions on the node to identify and list nodes based on their scores. Subsequently, this scheduler communicates the scored listing to the API server, which then instructs kubelet to run the pod on the designated node.

However, it's possible to deploy pods without utilizing the API server, scheduler, or etcd. Enter static pods: pods managed solely by kubelet.

To deploy a static pod, you create a YAML file similar to one used for a regular pod. Configure kubelet to read the pod definition file from a specific directory and place this file in the designated location.

Kubelet periodically checks this directory. Upon detecting a new definition file, it creates a new pod based on that file. Kubelet also monitors the pod's lifecycle, performs restarts if necessary, and checks for changes in the file. Deleting the pod is as simple as removing the file from the directory.

Static pod functionality is limited to pods exclusively.

Now, where does this directory path reside?

The path is /etc/kubernetes/manifests. You can modify the directory location in the kubelet.service file.

Once the pod is created, you can use Docker installed on the system to view this pod.

Run: docker ps

A common question arises: Does kube-apiserver recognize this pod on the node if the kube-apiserver is available?

Yes, kube-apiserver has read-only access to details related to the pod. However, updates or deletions to this pod aren't allowed.

But why would you need static pods?

The primary purpose is to deploy control plane components on nodes. Kubeadm harnesses static pods for setting up Kubernetes.

Understanding static pods provides a unique insight into Kubernetes' deployment flexibility.

Thanks for reading. It is just a simple understanding of static pods. Hope you had fun reading this and you might have learned something new as well.