Skip to content

Managing Worker Nodes

Introduction#

When deploying your ROSA cluster, you can configure many aspects of your worker nodes, but what happens when you need to change your worker nodes after they've already been created? These activities include scaling the number of nodes, changing the instance type, adding labels or taints, just to name a few.

Many of these changes are done using MachinePools. MachinePools ensure that a specified number of Machine replicas are running at any given time. Think of a MachinePool as a "template" for the kinds of Machines that make up the worker nodes of your cluster. If you'd like to learn more, see the Red Hat documentation on worker node management.

Scaling worker nodes#

Via the CLI#

  1. First, let's see what MachinePools already exist in our cluster. To do so, run the following command:

    rosa list machinepools -c ${WS_USER/_/-}
    

    Your output should look similar to:

    ID       AUTOSCALING  REPLICAS  INSTANCE TYPE  LABELS    TAINTS    AVAILABILITY ZONES                    SUBNETS    SPOT INSTANCES
    Default  No           3         m5.xlarge                          us-east-1a, us-east-1b, us-east-1c               N/A
    
  2. Now, let's take a look at the machines inside of the ROSA cluster that have been created according to the instructions provided by the above MachinePools. To do so, run the following command:

    oc -n openshift-machine-api get machine
    

    For this workshop, we've deployed your ROSA cluster with nine total machines (three workers, three control planes, and three infrastructure nodes), one in each availability zone. The output will look something like this:

    NAME                                         PHASE     TYPE         REGION      ZONE         AGE
    user1-mobbws-6sj5f-infra-us-east-1a-cb56h    Running   r5.xlarge    us-east-1   us-east-1a   18h
    user1-mobbws-6sj5f-infra-us-east-1b-t6bdg    Running   r5.xlarge    us-east-1   us-east-1b   18h
    user1-mobbws-6sj5f-infra-us-east-1c-9v4pq    Running   r5.xlarge    us-east-1   us-east-1c   18h
    user1-mobbws-6sj5f-master-0                  Running   m5.2xlarge   us-east-1   us-east-1a   18h
    user1-mobbws-6sj5f-master-1                  Running   m5.2xlarge   us-east-1   us-east-1b   18h
    user1-mobbws-6sj5f-master-2                  Running   m5.2xlarge   us-east-1   us-east-1c   18h
    user1-mobbws-6sj5f-worker-us-east-1a-jrxnz   Running   m5.xlarge    us-east-1   us-east-1a   18h
    user1-mobbws-6sj5f-worker-us-east-1b-2j8lc   Running   m5.xlarge    us-east-1   us-east-1b   18h
    user1-mobbws-6sj5f-worker-us-east-1c-w8jl6   Running   m5.xlarge    us-east-1   us-east-1c   18h
    
  3. Now that we know that we have three worker nodes, let's create a MachinePool to add a new worker node using the ROSA CLI. To do so, run the following command:

    rosa create machinepool -c ${WS_USER/_/-} --availability-zone ${AWS_DEFAULT_REGION}a --replicas 1 --name workshop --instance-type m5.xlarge
    

    The output of the command should look something like this:

    I: Fetching instance types
    I: Machine pool 'workshop' created successfully on cluster 'user1-mobbws'
    I: To view all machine pools, run 'rosa list machinepools -c user1-mobbws'
    

    This command adds a single m5.xlarge instance to the us-east-1a availability zone.

  4. Now, let's scale up our selected MachinePool from one to two machines. To do so, run the following command:

    rosa update machinepool -c ${WS_USER/_/-} --replicas 2 workshop
    

    Your output should look like this:

    I: Updated machine pool 'workshop' on cluster 'user1-mobbws'
    
  5. Now that we've scaled the MachineSet to two machines, we can see that the machine is already being created. First, let's quickly check the output of the same command we ran in step 1:

    oc -n openshift-machine-api get machinesets
    

    The output should look something like this:

    NAME                                      DESIRED   CURRENT   READY   AVAILABLE   AGE
    user1-mobbws-6sj5f-infra-us-east-1a       1         1         1       1           18h
    user1-mobbws-6sj5f-infra-us-east-1b       1         1         1       1           18h
    user1-mobbws-6sj5f-infra-us-east-1c       1         1         1       1           18h
    user1-mobbws-6sj5f-worker-us-east-1a      1         1         1       1           19h
    user1-mobbws-6sj5f-worker-us-east-1b      1         1         1       1           19h
    user1-mobbws-6sj5f-worker-us-east-1c      1         1         1       1           19h
    user1-mobbws-6sj5f-workshop-us-east-1a    2         2         1       1           4m36s
    

    Note, that the number of desired and current nodes matches the scale we specified, but only one is ready and available.

    We can also run the same command we ran in step 2 to see the machine being provisioned:

    oc -n openshift-machine-api get machine
    

    The output should look something like this:

    NAME                                            PHASE         TYPE         REGION      ZONE         AGE
    user1-mobbws-6sj5f-infra-us-east-1a-cb56h       Running       r5.xlarge    us-east-1   us-east-1a   18h
    user1-mobbws-6sj5f-infra-us-east-1b-t6bdg       Running       r5.xlarge    us-east-1   us-east-1b   18h
    user1-mobbws-6sj5f-infra-us-east-1c-9v4pq       Running       r5.xlarge    us-east-1   us-east-1c   18h
    user1-mobbws-6sj5f-master-0                     Running       m5.2xlarge   us-east-1   us-east-1a   19h
    user1-mobbws-6sj5f-master-1                     Running       m5.2xlarge   us-east-1   us-east-1b   19h
    user1-mobbws-6sj5f-master-2                     Running       m5.2xlarge   us-east-1   us-east-1c   19h
    user1-mobbws-6sj5f-worker-us-east-1a-jrxnz      Running       m5.xlarge    us-east-1   us-east-1a   18h
    user1-mobbws-6sj5f-worker-us-east-1b-2j8lc      Running       m5.xlarge    us-east-1   us-east-1b   18h
    user1-mobbws-6sj5f-worker-us-east-1c-w8jl6      Running       m5.xlarge    us-east-1   us-east-1c   18h
    user1-mobbws-6sj5f-workshop-us-east-1a-6gz7w    Provisioned   m5.xlarge    us-east-1   us-east-1a   51s
    user1-mobbws-6sj5f-workshop-us-east-1a-xh584    Running       m5.xlarge    us-east-1   us-east-1a   3m43s
    
  6. Now let's scale the cluster back down to a total of 4 worker nodes by scaling down the "Workshop" Machine Pool. To do so, run the following command:

    rosa update machinepool -c ${WS_USER/_/-} --replicas 1 workshop
    
  7. Now that we've scaled the MachineSet back down to one machines, we can see the change reflected in the cluster almost immediately. Let's quickly check the output of the same command we ran in step 5:

    oc -n openshift-machine-api get machinesets
    

    The output should look something like this:

    NAME                                      DESIRED   CURRENT   READY   AVAILABLE   AGE
    user1-mobbws-6sj5f-infra-us-east-1a       1         1         1       1           18h
    user1-mobbws-6sj5f-infra-us-east-1b       1         1         1       1           18h
    user1-mobbws-6sj5f-infra-us-east-1c       1         1         1       1           18h
    user1-mobbws-6sj5f-worker-us-east-1a      1         1         1       1           19h
    user1-mobbws-6sj5f-worker-us-east-1b      1         1         1       1           19h
    user1-mobbws-6sj5f-worker-us-east-1c      1         1         1       1           19h
    user1-mobbws-6sj5f-workshop-us-east-1a    1         1         1       1           4m36s
    
  8. Now let's scale the cluster back down to a total of 3 worker nodes by deleting the "Workshop" Machine Pool. To do so, run the following command:

    rosa delete machinepool -c ${WS_USER/_/-} workshop --yes
    

Congratulations! You've successfully scaled your cluster up and back down to three nodes.