π οΈ Manual Scheduling in Kubernetes
By default, Kubernetes uses the scheduler to assign Pods to nodes. But you can manually schedule a Pod by specifying the nodeName field β bypassing the scheduler entirely.
π§Ύ Use Cases
- Debugging scheduler behavior
- Manually placing a Pod on a specific node
- Simple test setups or demos
π§± YAML Example: Manual Scheduling
apiVersion: v1
kind: Pod
metadata:
name: manual-pod
spec:
containers:
- name: nginx
image: nginx
nodeName: worker-node-1
This Pod will only run on
worker-node-1, assuming the node exists and is schedulable.
π Get Available Node Names
kubectl get nodes
π« What Happens if Node Is Unavailable?
- Pod stays in
Pendingstate - Events will show
FailedSchedulingwith no matching node
π Switching Back to Scheduler
To let the scheduler choose the node again, simply remove the nodeName field and apply the Pod definition anew.
π§ͺ Alternative: kubectl run with Node Selector
While not full manual scheduling, you can use nodeSelector to influence placement:
kubectl run nginx --image=nginx --overrides='{
"apiVersion": "v1",
"spec": {
"nodeName": "worker-node-1"
}
}' --dry-run=client -o yaml | kubectl apply -f -
β Caution
- Manual scheduling does not consider taints, affinities, or resource constraints
- You must know what you're doing β thereβs no safety net
β Summary
Manual scheduling with nodeName: is useful for learning and debugging, but not recommended for production workloads.
Use it only when you need full control over placement and understand the cluster state.