Pod Scheduling Gates

A Pod was created a minute ago and still has no Node, yet the Scheduler has not even once tried to place it or marked it unschedulable. What is holding it back, and what lets the Scheduler make its first try?

Play the animation 6 steps, animated, plays on a computer or a tablet

Pod Scheduling Gates, Kubernetes diagram

Pod Scheduling Gates, step by step

  1. A Pod is created with two entries in spec.schedulingGates, and while they stand the Scheduler makes no attempt to place it. Each entry is an opaque criterion that some other component owns. A gate can only be set while the Pod is being created, by the client that posts it or by an admission plugin that mutates it on the way in.

    Play from step 1
  2. While the list holds any entry the Pod never enters the active queue, so the Scheduler runs no cycle on it and no Node is ever filtered or scored. That is not the same as unschedulable, which means a scheduling attempt was made and failed. The metric scheduler_pending_pods separates the two by its queue label, and this Pod is counted under gated.

    Play from step 2
  3. The component that owns example.com/bar patches it out of the list. Entries come off in any order, and this one was second, so removing it says nothing about the other. Nothing else moves. STATUS still reads SchedulingGated and the PodScheduled condition is still False, because one entry left in the list is enough to hold the Pod out.

    Play from step 3
  4. After creation the API accepts a removal and refuses an addition. A component that lets its gate go cannot put it back, and a Pod created without gates can never get one. So anything that wants to hold a Pod with a gate has to put it on at creation.

    Play from step 4
  5. The last entry goes the same way and the list is now empty. The empty list is the whole trigger. There is no separate signal and this Pod waits on nothing else, so the moment spec.schedulingGates has no entries left the Pod is ready to be considered for scheduling.

    Play from step 5
  6. The Pod joins the active queue, and the Scheduler can now make its first attempt. Only the metric moves, to queue active. STATUS and the PodScheduled reason still read SchedulingGated, because the API server wrote that condition at creation and nothing rewrites it until the Scheduler finishes an attempt. Next comes the ordinary cycle: filter the Nodes, score, and bind.

    Play from step 6

Sources