kubectl nodeSelector node selector - ghdrako/doc_snipets GitHub Wiki

show the existing labels on each node in our cluster

k get no --show-labels

apply a label to a node

k label no kind-worker disktype=ssd

Now that the worker node is labeled, we can add the node selector to our Pod YAML to ensure that the Pod gets scheduled to this newly labeled node.

   ...
   spec:
     ...
     nodeSelector:
       disktype: ssd
     ...
k apply -f ssd-pod.yaml

Show on witch node scheduled

k get po -o wide

Adding a node name instead of a node selector

A DaemonSet is a type of Kubernetes object that ensures that one Pod replica is always running on every single node in the cluster at all times. Even if you delete the Pod, the DaemonSet will respawn the Pod on any node that’s missing that DaemonSet’s Pod. DaemonSets use the node name attribute for all Pods within a DaemonSet to schedule Pods to specific nodes by their name. This ensures that one and only one Pod is assigned to a node, and by using the node name, they ensure that there aren’t accidentally two Pods running on a single node

   ...
   nodeName: kind-kontrol-plain
   ...