×

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

On Red Hat Virtualization (RHV), you can also change a machine set to provision new nodes on a different storage domain.

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

Modifying a machine set by using the CLI

When you modify a machine set, your changes only apply to 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 machine set.

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

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

Prerequisites
  • Your OpenShift Container Platform 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 machine set:

    $ 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.

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

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

    $ oc get -n openshift-machine-api machines -l machine.openshift.io/cluster-api-machineset=<machine_set_name>
    Example output
    NAME                        PHASE     TYPE         REGION      ZONE         AGE
    <machine_name_original_1>   Running   m6i.xlarge   us-west-1   us-west-1a   4h
    <machine_name_original_2>   Running   m6i.xlarge   us-west-1   us-west-1a   4h
  5. For each machine that is managed by the updated machine set, set the delete annotation by running the following command:

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

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

    $ oc get -n openshift-machine-api machines -l machine.openshift.io/cluster-api-machineset=<machine_set_name>
    Example output
    NAME                        PHASE          TYPE         REGION      ZONE         AGE
    <machine_name_original_1>   Running        m6i.xlarge   us-west-1   us-west-1a   4h
    <machine_name_original_2>   Running        m6i.xlarge   us-west-1   us-west-1a   4h
    <machine_name_updated_1>    Provisioned    m6i.xlarge   us-west-1   us-west-1a   55s
    <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 machine set to the original number of replicas.

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

    $ oc scale --replicas=2 \(1)
      machineset <machine_set_name> \
      -n openshift-machine-api
    1 The original example value of 2.
Verification
  • To verify that the machines without the updated configuration are deleted, list the machines that are managed by the updated machine set by running the following command:

    $ oc get -n openshift-machine-api machines -l machine.openshift.io/cluster-api-machineset=<machine_set_name>
    Example output while deletion is in progress
    NAME                        PHASE           TYPE         REGION      ZONE         AGE
    <machine_name_original_1>   Deleting        m6i.xlarge   us-west-1   us-west-1a   4h
    <machine_name_original_2>   Deleting        m6i.xlarge   us-west-1   us-west-1a   4h
    <machine_name_updated_1>    Running         m6i.xlarge   us-west-1   us-west-1a   5m41s
    <machine_name_updated_2>    Running         m6i.xlarge   us-west-1   us-west-1a   5m41s
    Example output when deletion is complete
    NAME                        PHASE           TYPE         REGION      ZONE         AGE
    <machine_name_updated_1>    Running         m6i.xlarge   us-west-1   us-west-1a   6m30s
    <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:

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

Migrating nodes to a different storage domain on RHV

You can migrate the OpenShift Container Platform control plane and compute nodes to a different storage domain in a Red Hat Virtualization (RHV) cluster.

Migrating compute nodes to a different storage domain in RHV

Prerequisites
  • You are logged in to the Manager.

  • You have the name of the target storage domain.

Procedure
  1. Identify the virtual machine template:

    $ oc get -o jsonpath='{.items[0].spec.template.spec.providerSpec.value.template_name}{"\n"}' machineset -A
  2. Create a new virtual machine in the Manager, based on the template you identified. Leave all other settings unchanged. For details, see Creating a Virtual Machine Based on a Template in the Red Hat Virtualization Virtual Machine Management Guide.

    You do not need to start the new virtual machine.

  3. Create a new template from the new virtual machine. Specify the target storage domain under Target. For details, see Creating a Template in the Red Hat Virtualization Virtual Machine Management Guide.

  4. Add a new machine set to the OpenShift Container Platform cluster with the new template.

    1. Get the details of the current machine set:

      $ oc get machineset -o yaml
    2. Use these details to create a machine set. For more information see Creating a machine set.

      Enter the new virtual machine template name in the template_name field. Use the same template name you used in the New template dialog in the Manager.

    3. Note the names of both the old and new machine sets. You need to refer to them in subsequent steps.

  5. Migrate the workloads.

    1. Scale up the new machine set. For details on manually scaling machine sets, see Scaling a machine set manually.

      OpenShift Container Platform moves the pods to an available worker when the old machine is removed.

    2. Scale down the old machine set.

  6. Remove the old machine set:

    $ oc delete machineset <machineset-name>

Migrating control plane nodes to a different storage domain on RHV

OpenShift Container Platform does not manage control plane nodes, so they are easier to migrate than compute nodes. You can migrate them like any other virtual machine on Red Hat Virtualization (RHV).

Perform this procedure for each node separately.

Prerequisites
  • You are logged in to the Manager.

  • You have identified the control plane nodes. They are labeled master in the Manager.

Procedure
  1. Select the virtual machine labeled master.

  2. Shut down the virtual machine.

  3. Click the Disks tab.

  4. Click the virtual machine’s disk.

  5. Click More Actionskebab and select Move.

  6. Select the target storage domain and wait for the migration process to complete.

  7. Start the virtual machine.

  8. Verify that the OpenShift Container Platform cluster is stable:

    $ oc get nodes

    The output should display the node with the status Ready.

  9. Repeat this procedure for each control plane node.