Skip to content
LF Cert Trainer

Lesson 27 · Section 3: Scheduling

Lesson 27: Manual scheduling: placing a Pod without the scheduler

How a Pod gets a node when you choose it yourself: the nodeName field, the Binding object, which safety checks you lose, and the exam routine for a Pod that is Pending because no scheduler is running. · 15 min read · 4 min video

1/10Manual scheduling
0:00 / 3:50

Narrated by the local narrator voice. Keys: Space plays and pauses, J and L step, C captions, F full screen.

What manual scheduling is

In the kube-scheduler lesson you saw that the scheduler's whole output is one field. It watches for Pods whose spec.nodeName is empty, picks a node, and has the API server write that node's name into the field. Everything after that is the kubelet's work.

Manual scheduling means you write that field yourself. No component has to agree with you: the Pod arrives in the API with a node already on it, so the scheduler never sees it as work to do, and the kubelet on the named node starts it like any other Pod assigned to it.

Two ways a Pod gets its nodependingnode-1skipsdirectPod webnodeName: emptykube-schedulerfilter, score, bindkubelet node-1starts webPod dbnodeName: node-2No schedulerPod is ignoredkubelet node-2starts db
Two ways a Pod gets its node. Scheduling means filling in one field. The scheduler normally fills it in for you; with nodeName you fill it in yourself and the scheduler never looks at the Pod.

Parts:

  • Pod web (nodeName: empty)
  • kube-scheduler (filter, score, bind)
  • kubelet node-1 (starts web)
  • Pod db (nodeName: node-2)
  • No scheduler (Pod is ignored)
  • kubelet node-2 (starts db)

Connections:

  • Pod web to kube-scheduler: pending
  • kube-scheduler to kubelet node-1: node-1
  • Pod db to No scheduler: skips
  • No scheduler to kubelet node-2: direct

You will need this in three situations:

  • The scheduler is not running. A cluster without a scheduler leaves every new Pod Pending. This is a favourite exam scenario, and manual scheduling is how you get a Pod running without repairing the control plane first.
  • A task tells you to. "Schedule the Pod on node01 without using the scheduler" has exactly one answer.
  • Testing and debugging. You want one throwaway Pod on one specific node, now, to test its network or disk.

How it works

The scheduler only looks at Pods without a node

The scheduler asks the API server for Pods whose spec.nodeName is empty. You can ask the same question:

kubectl get pods -A --field-selector spec.nodeName=

A Pod created with nodeName already set never appears in that list. The scheduler does not check it, approve it or even record an event for it. On the other side, each kubelet watches for Pods whose spec.nodeName equals its own node name. It does not care how the name got there.

One visible consequence: a Pod placed by hand has no Scheduled event. Its event list starts with the kubelet's Pulling or Pulled.

Events:
  Type    Reason   Age   From     Message
  Normal  Pulled   6s    kubelet  Container image "redis:8-alpine" already present on machine
  Normal  Created  6s    kubelet  Created container: db
  Normal  Started  6s    kubelet  Started container db

nodeName is write-once

You can set nodeName when you create a Pod. After that it is fixed. Like most of the Pod spec it cannot be edited, and the API server refuses the change:

The Pod "web" is invalid: spec: Forbidden: pod updates may not change fields other than
`spec.containers[*].image`, `spec.initContainers[*].image`, `spec.activeDeadlineSeconds`, `spec.tolerations`
(only additions to existing tolerations), `spec.terminationGracePeriodSeconds` ...

This holds in both directions. You cannot give a node to a Pending Pod by editing it, and you cannot move a running Pod to another node by changing the field. A Pod is never moved; it is deleted and a new one is created elsewhere.

The Binding object: how the scheduler itself does it

If the field cannot be edited, how does the scheduler set it on a Pod that already exists? It does not update the Pod. It sends a separate request: a Binding object, posted to the Pod's binding subresource.

Binding a Pod that already existswritePOSTsets nodeNamewatchstartsYouact as the schedulerBindingweb → node-2API serverpods/web/bindingPod webnodeName: node-2kubelet node-2watches its PodsContainersRunning
Binding a Pod that already exists. nodeName cannot be edited on a live Pod. A Binding is the one request that may set it, once, and it is the same request the scheduler sends.

Parts:

  • You (act as the scheduler)
  • Binding (web → node-2)
  • API server (pods/web/binding)
  • Pod web (nodeName: node-2)
  • kubelet node-2 (watches its Pods)
  • Containers (Running)

Connections:

  • You to Binding: write
  • Binding to API server: POST
  • API server to Pod web: sets nodeName
  • Pod web to kubelet node-2: watch
  • kubelet node-2 to Containers: starts
{
  "apiVersion": "v1",
  "kind": "Binding",
  "metadata": { "name": "web" },
  "target": { "apiVersion": "v1", "kind": "Node", "name": "node-2" }
}

metadata.name is the name of the Pod, and target is the node. When the API server accepts the Binding it sets spec.nodeName on the Pod and marks its PodScheduled condition as true. You can post the same object yourself, which makes you the scheduler for that one Pod. A Binding works once: if the Pod already has a node, the request is refused with pod web is already assigned to node "node-1".

Which checks are skipped, and which remain

What still protects a hand-placed Podnot askeddirectfitstoo bignot toleratedPod dbnodeName: node-2Scheduler filtersskipped entirelykubelet node-2its own checksRunningtaint, cordon ignoredFailedOutOfcpu, OutOfmemoryEvictedNoExecute taint
What still protects a hand-placed Pod. Every scheduler filter is skipped. Only the kubelet on the named node still has a say, and it does not look for a better node: it runs the Pod or fails it.

Parts:

  • Pod db (nodeName: node-2)
  • Scheduler filters (skipped entirely)
  • kubelet node-2 (its own checks)
  • Running (taint, cordon ignored)
  • Failed (OutOfcpu, OutOfmemory)
  • Evicted (NoExecute taint)

Connections:

  • Pod db to Scheduler filters: not asked
  • Pod db to kubelet node-2: direct
  • kubelet node-2 to Running: fits
  • kubelet node-2 to Failed: too big
  • kubelet node-2 to Evicted: not tolerated

The scheduler's filters are what normally keep a Pod off an unsuitable node. With nodeName none of them run.

ProtectionWith the schedulerWith nodeName
NoSchedule taintPod is kept off the node unless it tolerates the taintIgnored. The Pod runs on the node
Cordoned node (SchedulingDisabled)No new Pods are placed thereIgnored. The Pod runs on the node
CPU and memory requestsNode must have enough unreserved capacityNot compared first. The kubelet fails a Pod that does not fit: status OutOfcpu or OutOfmemory
nodeSelector and affinity rulesFilter or rank the nodesOverruled: nodeName has already decided
NoExecute taintPod is kept off the nodeStill applies. The Pod is evicted unless it tolerates the taint
Node exists and is healthyOnly real, ready nodes are consideredNot checked. See below

Two of these deserve a closer look.

A wrong node name fails silently. The API server does not check that the node exists. If you write nodeName: node-22 and there is no such node, the Pod is accepted, the scheduler ignores it because it has a node, and no kubelet claims it because no node has that name. The Pod stays Pending with no events, and after a while the control plane may delete it as an orphan. Nothing tells you about the typo.

A Pod that does not fit is failed, not rescheduled. The kubelet has its own last check when it admits a Pod. If the Pod's requests exceed what the node has left, the kubelet rejects it and the Pod ends in phase Failed:

NAME   READY   STATUS     RESTARTS   AGE   NODE
big    0/1     OutOfcpu   0          4s    node-2

Nobody looks for a better node, because looking for nodes is the scheduler's job and you bypassed it.

Under the hood · Who else sets nodeName without the scheduler?
  • Static Pods. The kubelet reads a manifest from its own disk and runs it. The mirror Pod you see in the API already has spec.nodeName set to that kubelet's node. This is how the scheduler itself can run before any scheduler exists.
  • Custom schedulers. A second scheduler is simply another program that watches for Pods carrying its schedulerName and posts Bindings for them. The Binding request is the public interface for "this Pod goes on that node".
  • DaemonSets, in the past. The DaemonSet controller used to set nodeName directly. Today it adds a node affinity for one node to each Pod and lets the default scheduler bind it, so taints and resources are respected.

The Kubernetes documentation is direct about the intended audience: nodeName exists for custom schedulers and for advanced cases where you must bypass the configured schedulers. For "run this on that node", it recommends nodeSelector or node affinity instead.

nodeName compared with the alternatives

You wantUseScheduler involved
This Pod on exactly this node, now, no questions askedspec.nodeNameNo
A Pod on a node with a certain labelspec.nodeSelectorYes
The same, with richer rules or soft preferencesNode affinityYes
A Pod on one named node, but with all checks onnodeSelector with kubernetes.io/hostname: node-2Yes
One Pod on every nodeDaemonSetYes
A Pod owned by the node itself, not the APIStatic PodNo

The fourth row is the one to remember for real clusters: every node carries the label kubernetes.io/hostname, so you can pin a Pod to a single node and still keep taints, cordons and resource checks.

Using it

Example · Create a Pod on a node you choose

Find the exact node name first, then generate the Pod and add one line:

kubectl get nodes
kubectl run db --image=redis:8-alpine --dry-run=client -o yaml > db.yaml
apiVersion: v1
kind: Pod
metadata:
  name: db
spec:
  nodeName: node-2          # same level as containers
  containers:
    - name: db
      image: redis:8-alpine
kubectl apply -f db.yaml
kubectl get pod db -o wide                  # NODE shows node-2

There is no kubectl run flag for the node, but you can skip the file with an override:

kubectl run db --image=redis:8-alpine --overrides='{"spec":{"nodeName":"node-2"}}'

Example · Rescue a Pending Pod when there is no scheduler

The Pod web has been Pending for minutes. Confirm the cause before you touch anything:

kubectl describe pod web | tail -n 3        # Events: <none>, so nobody tried
kubectl -n kube-system get pods -l component=kube-scheduler   # nothing listed

No events and no scheduler Pod: the cluster has no scheduler. Place the Pod yourself. Because nodeName cannot be added to a live Pod, recreate it:

kubectl get nodes                           # pick a worker, for example node-2
kubectl get pod web -o yaml > web.yaml
vi web.yaml                                 # add "nodeName: node-2" under spec
kubectl replace --force -f web.yaml         # deletes the Pod, then creates it
kubectl get pod web -o wide
NAME   READY   STATUS    RESTARTS   AGE   IP           NODE
web    1/1     Running   0          8s    10.244.2.7   node-2

You do not need to clean the exported file. The API server ignores status and replaces the server-managed metadata.

Example · Bind a Pending Pod without deleting it

When the Pod must not be recreated, do what the scheduler does and post a Binding. Save the object as binding.json:

{
  "apiVersion": "v1",
  "kind": "Binding",
  "metadata": { "name": "web" },
  "target": { "apiVersion": "v1", "kind": "Node", "name": "node-2" }
}

Send it to the Pod's binding subresource. kubectl create --raw posts a file to any API path with your normal credentials:

kubectl create --raw /api/v1/namespaces/default/pods/web/binding -f binding.json
kubectl get pod web -o wide                 # Running on node-2, same Pod, same UID

The same request with curl, through kubectl proxy:

kubectl proxy --port=8001 &
curl -X POST -H "Content-Type: application/json" --data @binding.json \
  http://localhost:8001/api/v1/namespaces/default/pods/web/binding

The path contains the namespace and the Pod name, so change both for another Pod. In the exam the recreate route is usually quicker; know this one for tasks that forbid deleting the Pod.

Example · See what nodeName lets through

On a practice cluster, prove to yourself that the scheduler's checks are gone. Cordon a node, then place a Pod on it by name:

kubectl cordon node-2
kubectl run a --image=nginx:1.29-alpine                                              # scheduler avoids node-2
kubectl run b --image=nginx:1.29-alpine --overrides='{"spec":{"nodeName":"node-2"}}'
kubectl get pods -o wide
NAME   READY   STATUS    RESTARTS   AGE   IP           NODE
a      1/1     Running   0          9s    10.244.1.4   node-1
b      1/1     Running   0          5s    10.244.2.9   node-2

Pod b runs on a node marked SchedulingDisabled. The same happens on a control plane node with its NoSchedule taint. Clean up with kubectl uncordon node-2 and kubectl delete pod a b.

Tricks

Common mistakes

  • Putting nodeName in the wrong place. It belongs directly under spec, at the same level as containers. Under metadata, or inside a container, it is rejected or ignored. kubectl explain pod.spec.nodeName confirms the path.
  • Trying to kubectl edit a Pending Pod to add the node. The API server refuses. Recreate the Pod with kubectl replace --force -f, or post a Binding.
  • Confusing nodeName with nodeSelector. nodeName takes a node's name and bypasses the scheduler. nodeSelector takes labels and is enforced by the scheduler.
  • Expecting taints or a cordon to stop the Pod. Both are scheduler rules. Only a NoExecute taint still acts on a hand-placed Pod, by evicting it after it lands.
  • Using manual scheduling to fix FailedScheduling. If the scheduler said no for "Insufficient cpu", forcing the Pod onto the node only turns a Pending Pod into a Failed one.
  • Leaving nodeName in a Deployment template. All replicas pile onto one node and cannot survive losing it.

Recap

  • A Pod is scheduled when spec.nodeName is set. Manual scheduling means setting it yourself.
  • The scheduler ignores any Pod that already has a node; the kubelet on that node just starts it.
  • nodeName can only be set at creation. For an existing Pod: kubectl replace --force -f, or post a Binding to /api/v1/namespaces/<ns>/pods/<pod>/binding.
  • All scheduler checks are skipped: NoSchedule taints, cordons, selectors and the capacity comparison.
  • The kubelet still fails a Pod that does not fit (OutOfcpu, OutOfmemory), and NoExecute taints still evict.
  • Pending with no events and no scheduler Pod is the signal to schedule by hand. Otherwise prefer nodeSelector or node affinity.

Official docs

Quiz: check what you learned

5 questions on this lesson · about 3 min · instant feedback. Missed questions come back in your review queue.

Sign in to take the quiz and keep your score.

Practise: try it on a real cluster

2 hands-on labs for this lesson. You get goals, not steps: any solution that reaches them passes.

  • Get a waiting pod onto a node while the cluster has no scheduler, and place a second pod on the control plane node, past its taint.

    Fix · Level 2 · standard · target 15 min

  • Section capstone on a three-node cluster. Reserve a node for one team, keep a search engine on fast disks, run an agent on every node whatever its taints, set resource defaults for a namespace, and place a Pod no scheduler will take.

    Build · Level 3 · challenge · target 35 min

Discussion

Learners ask and answer questions here. Sign in to read and join the discussion.