Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Whats the difference between "Pods" and "Static Pods" in kubernetes and when to choose "static pods" over regular pods

Tags:

kubernetes

New to kubernetes and looking to understand the best practice around using different kubernetes objects and have difficulty understanding what is a major difference between "Pods" and "Static Pods" functionally if there is any ?

Major questions as below :

Question 1: What is a major difference between "Pods" and "Static Pods" functionally if there is any ?

Question 2: When to choose "static pods" over regular pods.

like image 397
DT. Avatar asked Jan 06 '20 12:01

DT.


People also ask

Why we use static pod in Kubernetes?

Static Pods are always bound to one Kubelet on a specific node. The kubelet automatically tries to create a mirror Pod on the Kubernetes API server for each static Pod. This means that the Pods running on a node are visible on the API server, but cannot be controlled from there.

Why are static pods needed?

Static pods are usually used by software bootstrapping kubernetes itself. For example, kubeadm uses static pods to bringup kubernetes control plane components like api-server, controller-manager as static pods.

How do you identify a static pod?

I was able to identify Static Pods by looking at the metadata. labels. tier key/value pair with equal to "control-plane" with jq using the following. Static pods don't necessarily have a specific label, nor do they have to be on your master nodes.


2 Answers

Static pods are pods created and managed by kubelet daemon on a specific node without API server observing them. If the static pod crashes, kubelet restarts them. Control plane is not involved in lifecycle of static pod. Kubelet also tries to create a mirror pod on the kubernetes api server for each static pod so that the static pods are visible i.e., when you do kubectl get pod for example, the mirror object of static pod is also listed.

You almost never have to deal with static pods. Static pods are usually used by software bootstrapping kubernetes itself. For example, kubeadm uses static pods to bringup kubernetes control plane components like api-server, controller-manager as static pods. kubelet can watch a directory on the host file system (configured using --pod-manifest-path argument to kubelet) or sync pod manifests from a web url periodically (configured using --manifest-url argument to kubelet). When kubeadm is bringing up kubernetes control plane, it generates pod manifests for api-server, controller-manager in a directory which kubelet is monitoring. Then kubelet brings up these control plane components as static pods.

like image 78
Shashank V Avatar answered Oct 22 '22 10:10

Shashank V


One of the use case of static pod is kubernetes control plane bootstrapping. Kubeadm while bootstarping a kubernetes cluster creates API Server, controller manager , kube scheduler as a static pod because it can not create these as normal pod due to the fact that kube Api Server itself is not available yet.

like image 40
Arghya Sadhu Avatar answered Oct 22 '22 10:10

Arghya Sadhu