DEV Community

Ibrahim S
Ibrahim S

Posted on

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.

Billboard image

The fastest way to detect downtimes

Join Vercel, CrowdStrike, and thousands of other teams that trust Checkly to streamline monitoring.

Get started now

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

๐Ÿ‘‹ Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay