$ oc get machinesets.machine.openshift.io -n openshift-machine-api
You can modify a compute machine set, such as adding labels, changing the instance type, or changing block storage.
On Red Hat Virtualization (RHV), you can also change a compute machine set to provision new nodes on a different storage domain.
If you need to scale a compute machine set without making other changes, see Manually scaling a compute machine set. |
You can modify the configuration of a compute machine set, and then propagate the changes to the machines in your cluster by using the CLI.
By updating the compute machine set configuration, you can enable features or change the properties of the machines it creates.
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.
Changes made in the underlying cloud provider are not reflected in the |
You can replace the existing machines with new ones that reflect the updated configuration by scaling the compute machine set to create twice the number of replicas and then scaling it down to the original number of replicas.
If you need to scale a compute 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 compute machines.
Because the router is required to access some cluster resources, including the web console, do not scale the compute machine set to |
The output examples in this procedure use the values for an AWS cluster.
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
).
List the compute machine sets in your cluster by running the following command:
$ oc get machinesets.machine.openshift.io -n openshift-machine-api
NAME DESIRED CURRENT READY AVAILABLE AGE
<compute_machine_set_name_1> 1 1 1 1 55m
<compute_machine_set_name_2> 1 1 1 1 55m
Edit a compute machine set by running the following command:
$ oc edit machinesets.machine.openshift.io <machine_set_name> \
-n openshift-machine-api
Note the value of the spec.replicas
field, because 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 compute machine set that has a replicas value of 2 . |
Update the compute machine set CR with the configuration options that you want and save your changes.
List the machines that are managed by the updated compute machine set by running the following command:
$ oc get machines.machine.openshift.io \
-n openshift-machine-api \
-l machine.openshift.io/cluster-api-machineset=<machine_set_name>
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
For each machine that is managed by the updated compute machine set, set the delete
annotation by running the following command:
$ oc annotate machine.machine.openshift.io/<machine_name_original_1> \
-n openshift-machine-api \
machine.openshift.io/delete-machine="true"
To create replacement machines with the new configuration, scale the compute machine set to twice the number of replicas by running the following command:
$ oc scale --replicas=4 \(1)
machineset.machine.openshift.io <machine_set_name> \
-n openshift-machine-api
1 | The original example value of 2 is doubled to 4 . |
List the machines that are managed by the updated compute machine set by running the following command:
$ oc get machines.machine.openshift.io \
-n openshift-machine-api \
-l machine.openshift.io/cluster-api-machineset=<machine_set_name>
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 compute machine set to the original number of replicas.
To remove the machines that were created with the old configuration, scale the compute machine set to the original number of replicas by running the following command:
$ oc scale --replicas=2 \(1)
machineset.machine.openshift.io <machine_set_name> \
-n openshift-machine-api
1 | The original example value of 2 . |
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.openshift.io <machine_name_updated_1> \
-n openshift-machine-api
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:
$ oc get machines.machine.openshift.io \
-n openshift-machine-api \
-l machine.openshift.io/cluster-api-machineset=<machine_set_name>
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
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
You can migrate the OpenShift Container Platform control plane and compute nodes to a different storage domain in a Red Hat Virtualization (RHV) cluster.
You are logged in to the Manager.
You have the name of the target storage domain.
Identify the virtual machine template by running the following command:
$ oc get -o jsonpath='{.items[0].spec.template.spec.providerSpec.value.template_name}{"\n"}' machineset -A
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. |
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.
Add a new compute machine set to the OpenShift Container Platform cluster with the new template.
Get the details of the current compute machine set by running the following command:
$ oc get machineset -o yaml
Use these details to create a compute machine set. For more information see Creating a compute 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.
Note the names of both the old and new compute machine sets. You need to refer to them in subsequent steps.
Migrate the workloads.
Scale up the new compute machine set. For details on manually scaling compute machine sets, see Scaling a compute machine set manually.
OpenShift Container Platform moves the pods to an available worker when the old machine is removed.
Scale down the old compute machine set.
Remove the old compute machine set by running the following command:
$ oc delete machineset <machineset-name>
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.
You are logged in to the Manager.
You have identified the control plane nodes. They are labeled master in the Manager.
Select the virtual machine labeled master.
Shut down the virtual machine.
Click the Disks tab.
Click the virtual machine’s disk.
Click More Actions and select Move.
Select the target storage domain and wait for the migration process to complete.
Start the virtual machine.
Verify that the OpenShift Container Platform cluster is stable:
$ oc get nodes
The output should display the node with the status Ready
.
Repeat this procedure for each control plane node.