Kubernetes the hard way - How to set node unschedulable

7/3/2018

I am provisioning a Kubernets cluster from scratch (reasons). Its a local setup inside VM, and everything is fine, except the master node is created as schedulable.

I have tried assigning the master label and appropriate taint to node by passing required arguments to kubelet binary (doesn't solve the problem):

--register-with-taints=node-role.kubernetes.io/master=:NoSchedule
--node-labels=master,node-role.kubernetes.io/master=""

Here is the output from kubectl describe <node>:

Name:               myNodeName
Roles:              master
Labels:             beta.kubernetes.io/arch=amd64
                    beta.kubernetes.io/os=linux
                    kubernetes.io/hostname=myHostName
                    master=
                    node-role.kubernetes.io/master=
Annotations:        node.alpha.kubernetes.io/ttl=0
                    volumes.kubernetes.io/controller-managed-attach-detach=true
CreationTimestamp:  Tue, 03 Jul 2018 05:56:53 +0000
Taints:             node-role.kubernetes.io/master=true:NoSchedule
Unschedulable:      false

How do I set this node as Unschedulable? The documentation doesn't really specify this (feel free to direct to appropriate part of the documentation, in case I missed something).

PS: The labels/taints mentioned above were present before the node was created/registered.

-- Jaskaranbir Singh
kubernetes

1 Answer

7/3/2018

Taints get us a possibility to mark a node in order to prevent scheduler from using it for certain Pods with a NoSchedule parameter, and they have special values which Kubernetes Scheduler uses on the planning step. Pods by default cannot be spawned on nodes with taints until you will add tolerations which will allow scheduler to create pods on nodes with taints specified in toleration configuration; therefore, as per your node description, you have successfully registered this node as NoSchedule and it means that Pods will not be scheduled on this node.

Taints: node-role.kubernetes.io/master=true:NoSchedule

Alternatively, you can use kubectl cordon NODE command to mark the node as unschedulable; therefore it will disable scheduling for the node at all, so Kubernetes Scheduler will just ignore it in the process of planning workload, and it reflects in your node configuration like:

Unschedulable: true

-- mk_sta
Source: StackOverflow