Bootstrap FreeKB - OpenShift - Marking node as schedulable or unschedulable using the REST API
OpenShift - Marking node as schedulable or unschedulable using the REST API

Updated:   |  OpenShift articles

A node contains one or more pods, and each pod contains one or more containers.

The scheduler is responsible for determining which worker node a resource should get created on. For example, when deploying a new application to OpenShift, the scheduler determines which worker node the pod should be created on, typically the worker node with the most available memory and CPU. Check out my article on the default scheduler.

This assumes you have used the REST API to obtain an OAuth bearer token. Let's say the bearer token is sha256~0Rs__hPuXmBD3TJTXNDisC7wRBN-nrFnYTxgdBrFT-U.

Here is how you would return a specific node using curl.

curl
--insecure
--request GET
--header "Accept: application/json"
--header "Authorization: Bearer sha256~0Rs__hPuXmBD3TJTXNDisC7wRBN-nrFnYTxgdBrFT-U"
--url "https://api.openshift.example.com:6443/api/v1/nodes/my-node-2xqdt"

 

If the response contains something like this, this means the node is currently unschedulable. If the response does not contain JSON like this, then this should mean that pods can be scheduled to be run on the node.

    "spec": {
        "taints": [
            {
                "effect": "NoSchedule",
                "key": "node.kubernetes.io/unschedulable",
                "timeAdded": "2025-04-02T10:07:54Z"
            }
        ],
        "unschedulable": true
    },

 

Here is how you can update a node to be unschedulable using curl.

curl \
--insecure \
--request PATCH \
--header "Content-Type: application/merge-patch+json" \
--header "Authorization: Bearer sha256~0Rs__hPuXmBD3TJTXNDisC7wRBN-nrFnYTxgdBrFT-U" \
--url "https://api.openshift.example.com:6443/api/v1/nodes/my-worker-node-52wkr" \
--data '{"spec":{"unschedulable":true}}'

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 1ff54d in the box below so that we can be sure you are a human.