- What to schedule? — Pod
- Which node to schedule?
- Schedule/bind pod to node
How the scheduler uses nodeName
Every pod has a field called nodeName that is not set by default. Normally you do not set this field — Kubernetes auto-populates it. Here is how:
Run the scheduling algorithm
The scheduler runs its algorithm to identify the right node for the pod.
Scenario 1: No scheduler — set nodeName at creation time
If you do not have a scheduler in your cluster, deployed pods will remain in Pending state because nothing is monitoring and scheduling them.
You can manually assign a pod to a node by specifying nodeName in the pod spec at creation time.
sample.yaml
Scenario 2: Pod already exists — use a Binding object
If your pod is already created and you want to assign it to a node, you must create a Binding object and send a POST request to the pod’s binding API.binding.yaml
You must convert the YAML to JSON format before sending the POST request.