Modifying a compute machine set

You can modify a compute machine set, such as adding labels, changing the instance type, or changing block storage.

If you need to scale a compute machine set without making other changes, see Manually scaling a compute machine set.

Modifying a compute machine set by using the CLI

When you modify a compute machine set, your changes only apply to compute machines that are created after you save the updated MachineSet custom resource (CR). The changes do not affect existing machines. You can replace the existing machines with new ones that reflect the updated configuration by scaling the compute machine set.

If you need to scale a compute machine set without making other changes, you do not need to delete the machines.

By default, the OKD router pods are deployed on compute machines. Because the router is required to access some cluster resources, including the web console, do not scale the compute machine set to 0 unless you first relocate the router pods.

Prerequisites

  • Your OKD cluster uses the Machine API.

  • You are logged in to the cluster as an administrator by using the OpenShift CLI (oc).

Procedure

  1. Edit the compute machine set by running the following command:

    1. $ oc edit machineset <machine_set_name> -n openshift-machine-api
  2. Note the value of the spec.replicas field, as you need it when scaling the machine set to apply the changes.

    1. apiVersion: machine.openshift.io/v1beta1
    2. kind: MachineSet
    3. metadata:
    4. name: <machine_set_name>
    5. namespace: openshift-machine-api
    6. spec:
    7. replicas: 2 (1)
    8. # ...
    1The examples in this procedure show a compute machine set that has a replicas value of 2.
  3. Update the compute machine set CR with the configuration options that you want and save your changes.

  4. List the machines that are managed by the updated compute machine set by running the following command:

    1. $ oc get -n openshift-machine-api machines -l machine.openshift.io/cluster-api-machineset=<machine_set_name>

    Example output

    1. NAME PHASE TYPE REGION ZONE AGE
    2. <machine_name_original_1> Running m6i.xlarge us-west-1 us-west-1a 4h
    3. <machine_name_original_2> Running m6i.xlarge us-west-1 us-west-1a 4h
  5. For each machine that is managed by the updated compute machine set, set the delete annotation by running the following command:

    1. $ oc annotate machine/<machine_name_original_1> \
    2. -n openshift-machine-api \
    3. machine.openshift.io/delete-machine="true"
  6. Scale the compute machine set to twice the number of replicas by running the following command:

    1. $ oc scale --replicas=4 \(1)
    2. machineset <machine_set_name> \
    3. -n openshift-machine-api
    1The original example value of 2 is doubled to 4.
  7. List the machines that are managed by the updated compute machine set by running the following command:

    1. $ oc get -n openshift-machine-api machines -l machine.openshift.io/cluster-api-machineset=<machine_set_name>

    Example output

    1. NAME PHASE TYPE REGION ZONE AGE
    2. <machine_name_original_1> Running m6i.xlarge us-west-1 us-west-1a 4h
    3. <machine_name_original_2> Running m6i.xlarge us-west-1 us-west-1a 4h
    4. <machine_name_updated_1> Provisioned m6i.xlarge us-west-1 us-west-1a 55s
    5. <machine_name_updated_2> Provisioning m6i.xlarge us-west-1 us-west-1a 55s

    When the new machines are in the Running phase, you can scale the compute machine set to the original number of replicas.

  8. Scale the compute machine set to the original number of replicas by running the following command:

    1. $ oc scale --replicas=2 \(1)
    2. machineset <machine_set_name> \
    3. -n openshift-machine-api
    1The original example value of 2.

Verification

  • To verify that the compute machines without the updated configuration are deleted, list the machines that are managed by the updated compute machine set by running the following command:

    1. $ oc get -n openshift-machine-api machines -l machine.openshift.io/cluster-api-machineset=<machine_set_name>

    Example output while deletion is in progress

    1. NAME PHASE TYPE REGION ZONE AGE
    2. <machine_name_original_1> Deleting m6i.xlarge us-west-1 us-west-1a 4h
    3. <machine_name_original_2> Deleting m6i.xlarge us-west-1 us-west-1a 4h
    4. <machine_name_updated_1> Running m6i.xlarge us-west-1 us-west-1a 5m41s
    5. <machine_name_updated_2> Running m6i.xlarge us-west-1 us-west-1a 5m41s

    Example output when deletion is complete

    1. NAME PHASE TYPE REGION ZONE AGE
    2. <machine_name_updated_1> Running m6i.xlarge us-west-1 us-west-1a 6m30s
    3. <machine_name_updated_2> Running m6i.xlarge us-west-1 us-west-1a 6m30s
  • To verify that a machine created by the updated machine set has the correct configuration, examine the relevant fields in the CR for one of the new machines by running the following command:

    1. $ oc describe machine <machine_name_updated_1> -n openshift-machine-api

Additional resources