Advanced Scheduling in Kubernetes

Scheduler is a Kubernetes controller listening if a new pod is created and figure out right node by filtering and scoring

Node Affinity/Anti-Affinity

Affinity: If we need a pod to be in a node, based on key-label and value-label
Anti-Affinity: We don't want two replicas of pods in the same node

Node Affinity

Pod Anti-Affinity

TopologyKey — it looks for the hostname, if it matches it doesn’t schedule (since we mentioned podAntiAffinity) that pod to that node.

Taints and Tolerations

Taints — (on Nodes) Restriction of Pods to schedule on a Node
Toleration - (on Pods) Added to Pod that can Tolerate the Taint

Taints Example

kubectl taint nodes <node-name> key=value:taint-effect3 Taint Effects
1. NoSchedule - Taint & Toleration is checked during Scheduling
2. PreferNoSchedule - Not guaranteed
3. NoExecute - Existing pods that don't tolerate taint are ejected
pod definition

Update the evicted pods as in above image

Taint NoSchedule is set on Master node so that pods are not deployed on master node



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store