Static Pods, Manual Scheduling, Labels, and Selectors โ€” Kubernetes

ibrahimsi

Ibrahim S

Posted on July 31, 2024

Static Pods, Manual Scheduling, Labels, and Selectors โ€” Kubernetes

๐Ÿ”น The ๐—ž๐˜‚๐—ฏ๐—ฒ๐—ฟ๐—ป๐—ฒ๐˜๐—ฒ๐˜€ ๐˜€๐—ฐ๐—ต๐—ฒ๐—ฑ๐˜‚๐—น๐—ฒ๐—ฟ is in charge of scheduling pods onto nodes.

๐Ÿ”น The K8s scheduler is not responsible for actually running the pod โžก thatโ€™s the ๐—ธ๐˜‚๐—ฏ๐—ฒ๐—น๐—ฒ๐˜โ€™๐˜€ job. So it just needs to make sure every pod has a node assigned to it. Kubernetes in general has this idea of a "controller".

๐Ÿ”น Node selection in kube-scheduler. kube-scheduler selects a node for the pod in a 2-step operation:

โœ… Filtering
โœ… Scoring

๐Ÿ”น The filtering step finds the set of Nodes where it's ๐—ณ๐—ฒ๐—ฎ๐˜€๐—ถ๐—ฏ๐—น๐—ฒ ๐˜๐—ผ ๐˜€๐—ฐ๐—ต๐—ฒ๐—ฑ๐˜‚๐—น๐—ฒ the Pod.

๐Ÿ”น In the scoring step, the ๐˜€๐—ฐ๐—ต๐—ฒ๐—ฑ๐˜‚๐—น๐—ฒ๐—ฟ ๐—ฟ๐—ฎ๐—ป๐—ธ๐˜€ the remaining nodes to choose the most suitable Pod placement.

๐Ÿ”น The scheduler ๐—ฎ๐˜€๐˜€๐—ถ๐—ด๐—ป๐˜€ ๐—ฎ ๐˜€๐—ฐ๐—ผ๐—ฟ๐—ฒ ๐˜๐—ผ ๐—ฒ๐—ฎ๐—ฐ๐—ต ๐—ก๐—ผ๐—ฑ๐—ฒ that survived filtering, basing this score on the active scoring rules.

๐Ÿ”น Finally, the kube-scheduler assigns the Pod to the Node with the highest ranking. If there is more than ๐—ผ๐—ป๐—ฒ ๐—ป๐—ผ๐—ฑ๐—ฒ ๐˜„๐—ถ๐˜๐—ต ๐—ฒ๐—พ๐˜‚๐—ฎ๐—น ๐˜€๐—ฐ๐—ผ๐—ฟ๐—ฒ๐˜€, the kube-scheduler selects one of these at random.

๐Ÿ”น Static Pods in Kubernetes are a way to run pods that are ๐—บ๐—ฎ๐—ป๐—ฎ๐—ด๐—ฒ๐—ฑ ๐—ฑ๐—ถ๐—ฟ๐—ฒ๐—ฐ๐˜๐—น๐˜† ๐—ฏ๐˜† ๐˜๐—ต๐—ฒ ๐—ธ๐˜‚๐—ฏ๐—ฒ๐—น๐—ฒ๐˜ ๐—ผ๐—ป ๐—ฎ ๐—ป๐—ผ๐—ฑ๐—ฒ, rather than being managed by the Kubernetes control plane.

๐Ÿ”น Static Pods are not defined in the Kubernetes API server like regular pods but are instead created by placing pod definition files in a specific directory on a node.

๐Ÿ”น Each Kubernetes node has a directory, typically located at /etc/kubernetes/manifests (or) a directory specified in the Kubelet's configuration. This directory is where you place the static pod definition files.

๐Ÿ”น If the application pod crashes, kubelet attempts to restart it. kubelet running on the node monitors this directory for changes.

๐Ÿ”น All the pods that are created are managed by the API server and the scheduler schedules it based on the compute utilization of worker nodes.

๐Ÿ”น Manual scheduling refers to the scheduling of the pod through the YAML manifest with the keyword nodeName: node_name, which will schedule the pod in a specific node irrespective of the scheduler's availability.

๐Ÿ’– ๐Ÿ’ช ๐Ÿ™… ๐Ÿšฉ
ibrahimsi
Ibrahim S

Posted on July 31, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

ยฉ TheLazy.dev

About