InterviewHubPRO
Section Overview
Q14

Question 14 of 50

Part 2: Kubernetes Architecture & Core Workloads (11 - 25)

28%
DevOps & Kubernetes (50 Qs)•Part 2: Kubernetes Architecture & Core Workloads (11 - 25)

Kube-Scheduler Deep-Dive: How Filtering, Scoring, Node Affinity, Taints, and Tolerations place Pods.

Scheduling Pipeline & Algorithms

When a Pod is submitted with spec.nodeName == "", the kube-scheduler selects the best node in two primary phases: Filtering (Predicates) and Scoring (Priorities).

scss
[ Unschedulable Pod ]
         |
         v
+---------------------------------------------------+
| 1. Filtering Phase (Predicates)                   |
| - NodeResourcesFit (CPU, RAM available)           |
| - NodeName matches (if specified)                 |
| - PodFitsHostPorts                                |
| - NodeAffinity & NodeSelector                     |
| - Taints & Tolerations matching                   |
| - PodTopologySpreadConstraints                    |
+---------------------------------------------------+
         | (List of Feasible Candidate Nodes)
         v
+---------------------------------------------------+
| 2. Scoring Phase (Priorities)                     |
| - LeastAllocated (Balance load)                   |
| - MostAllocated (Bin-packing for cost saving)     |
| - ImageLocalityPriority (Image already cached)    |
| - InterPodAffinityPriority                        |
+---------------------------------------------------+
         | (Highest Scoring Node)
         v
[ Bind Pod to Node via API Server ]

Taints vs. Tolerations vs. Node Affinity

MechanismWhere it is setPurposeRule Syntax
TaintOn the NodeRepels Pods from being scheduled unless the Pod tolerates the taint.kubectl taint nodes node-1 dedicated=gpu:NoSchedule
TolerationIn the Pod specAllows (but does not force) a Pod to schedule onto a tainted node.tolerations: [{key: "dedicated", value: "gpu", effect: "NoSchedule"}]
Node AffinityIn the Pod specAttracts a Pod to specific nodes based on node labels.requiredDuringSchedulingIgnoredDuringExecution (hard) vs preferredDuringScheduling... (soft)

Production Topology Spread Example

Ensures Pod replicas are distributed evenly across Availability Zones:

yaml
topologySpreadConstraints:
  - maxSkew: 1
    topologyKey: topology.kubernetes.io/zone
    whenUnsatisfiable: DoNotSchedule
    labelSelector:
      matchLabels:
        app: payment-api