Home Using node selector to assign virtual mahcines to a node
Post
Cancel

Using node selector to assign virtual mahcines to a node

In some circumstances, we want to control which node the virtual machine or pod deploys to. The node selector can be used to assign virtual machine or pod to a node.

Add label to a node

The label can be added to a node from either command line or openshift web console.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$ oc get nodes
NAME                   STATUS                     ROLES    AGE   VERSION
master1   Ready                      master   46h   v1.20.11+63f841a
master2   Ready                      master   46h   v1.20.11+63f841a
master3   Ready                      master   46h   v1.20.11+63f841a
worker1    Ready                      worker   45h   v1.20.11+63f841a
worker2    Ready                      worker   45h   v1.20.11+63f841a
worker3    Ready,SchedulingDisabled   worker   45h   v1.20.11+63f841a

$ oc label nodes worker1 worker-node-name=w1

$ oc describe node worker1 | grep worker-node-name
                    worker-node-name=w1

$ oc get nodes --show-labels
NAME       STATUS                     ROLES    AGE   VERSION            LABELS
worker1    Ready                      worker   45h   v1.20.11+63f841a   <omitted..>worker-node-name=w1
<omitted..>

This can also be done through openshift web console by clicking the “edit labels” option on a node. Image

Add a nodeSelector field to the virtual machine

A node selector can be added through openshift web console.

Image

Image

1
2
3
4
$ oc describe vm vm1
    Spec:
      Node Selector:
        Worker - Node - Name:            w1

Reference

This post is licensed under CC BY 4.0 by the author.

Understanding thin provisioning volume and snapshot

Data volume units

Comments powered by Disqus.