Managing machines with the Cluster API
Important
Managing machines with the Cluster API is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.
For more information about the support scope of Red Hat Technology Preview features, see Technology Preview Features Support Scope.
Modifying a Cluster API machine template
You can update the machine template resource for your cluster by modifying the YAML manifest file and applying it with the OpenShift CLI (oc).
-
You have deployed an OpenShift Container Platform cluster that uses the Cluster API.
-
You have access to the cluster using an account with
cluster-adminpermissions. -
You have installed the OpenShift CLI (
oc).
-
List the machine template resource for your cluster by running the following command:
$ oc get <machine_template_kind>- Specify the value that corresponds to your platform.
The following values are valid:
Cluster infrastructure provider Value Amazon Web Services
AWSMachineTemplateGoogle Cloud
GCPMachineTemplateMicrosoft Azure
AzureMachineTemplateRHOSP
OpenStackMachineTemplateVMware vSphere
VSphereMachineTemplateBare metal
Metal3MachineTemplate AWSMachineTemplateGCPMachineTemplateAzureMachineTemplateOpenStackMachineTemplateVSphereMachineTemplateMetal3MachineTemplate
Example outputNAME AGE <template_name> 77m - Specify the value that corresponds to your platform.
The following values are valid:
-
Write the machine template resource for your cluster to a file that you can edit by running the following command:
$ oc get <machine_template_kind> <template_name> -o yaml > <template_name>.yamlwhere
<template_name>is the name of the machine template resource for your cluster. -
Make a copy of the
<template_name>.yamlfile with a different name. This procedure uses<modified_template_name>.yamlas an example file name. -
Use a text editor to make changes to the
<modified_template_name>.yamlfile that defines the updated machine template resource for your cluster. When editing the machine template resource, observe the following:-
The parameters in the
specstanza are provider specific. For more information, see the sample Cluster API machine template YAML for your provider. -
You must use a value for the
metadata.nameparameter that differs from any existing values.Important
For any Cluster API compute machine sets that reference this template, you must update the
spec.template.spec.infrastructureRef.nameparameter to match themetadata.namevalue in the new machine template resource.
-
-
Apply the machine template CR by running the following command:
$ oc apply -f <modified_template_name>.yaml- Use the edited YAML file with a new name.
-
For any Cluster API compute machine sets that reference this template, update the
spec.template.spec.infrastructureRef.nameparameter to match themetadata.namevalue in the new machine template resource. For more information, see "Modifying a compute machine set by using the CLI."
-
Sample YAML for a Cluster API machine template resource on Amazon Web Services
-
Sample YAML for a Cluster API machine template resource on Google Cloud
-
Sample YAML for a Cluster API machine template resource on Microsoft Azure
-
Sample YAML for a Cluster API machine template resource on RHOSP
-
Sample YAML for a Cluster API machine template resource on VMware vSphere
Modifying a compute machine set by using the CLI
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.
Note
Changes made in the underlying cloud provider are not reflected in the Machine or MachineSet CRs.
To adjust instance configuration in cluster-managed infrastructure, use the cluster-side resources.
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.
Note
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 0 unless you first relocate the router pods.
The output examples in this procedure use the values for an AWS cluster.
-
Your OpenShift Container Platform cluster uses the Cluster 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.cluster.x-k8s.io -n openshift-cluster-apiExample outputNAME CLUSTER REPLICAS READY AVAILABLE AGE VERSION <compute_machine_set_name_1> <cluster_name> 1 1 1 26m <compute_machine_set_name_2> <cluster_name> 1 1 1 26m -
Edit a compute machine set by running the following command:
$ oc edit machinesets.cluster.x-k8s.io <machine_set_name> \ -n openshift-cluster-api -
Note the value of the
spec.replicasfield, because you need it when scaling the machine set to apply the changes.apiVersion: cluster.x-k8s.io/v1beta1 kind: MachineSet metadata: name: <machine_set_name> namespace: openshift-cluster-api spec: replicas: 2 # ...- The examples in this procedure show a compute machine set that has a
replicasvalue of2.
- The examples in this procedure show a compute machine set that has a
-
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.cluster.x-k8s.io \ -n openshift-cluster-api \ -l cluster.x-k8s.io/set-name=<machine_set_name>Example output for an AWS clusterNAME CLUSTER NODENAME PROVIDERID PHASE AGE VERSION <machine_name_original_1> <cluster_name> <original_1_ip>.<region>.compute.internal aws:///us-east-2a/i-04e7b2cbd61fd2075 Running 4h <machine_name_original_2> <cluster_name> <original_2_ip>.<region>.compute.internal aws:///us-east-2a/i-04e7b2cbd61fd2075 Running 4h -
For each machine that is managed by the updated compute machine set, set the
deleteannotation by running the following command:$ oc annotate machines.cluster.x-k8s.io/<machine_name_original_1> \ -n openshift-cluster-api \ cluster.x-k8s.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 \ machinesets.cluster.x-k8s.io <machine_set_name> \ -n openshift-cluster-api- The original example value of
2is doubled to4.
- The original example value of
-
List the machines that are managed by the updated compute machine set by running the following command:
$ oc get machines.cluster.x-k8s.io \ -n openshift-cluster-api \ -l cluster.x-k8s.io/set-name=<machine_set_name>Example output for an AWS clusterNAME CLUSTER NODENAME PROVIDERID PHASE AGE VERSION <machine_name_original_1> <cluster_name> <original_1_ip>.<region>.compute.internal aws:///us-east-2a/i-04e7b2cbd61fd2075 Running 4h <machine_name_original_2> <cluster_name> <original_2_ip>.<region>.compute.internal aws:///us-east-2a/i-04e7b2cbd61fd2075 Running 4h <machine_name_updated_1> <cluster_name> <updated_1_ip>.<region>.compute.internal aws:///us-east-2a/i-04e7b2cbd61fd2075 Provisioned 55s <machine_name_updated_2> <cluster_name> <updated_2_ip>.<region>.compute.internal aws:///us-east-2a/i-04e7b2cbd61fd2075 Provisioning 55sWhen the new machines are in the
Runningphase, 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 \ machinesets.cluster.x-k8s.io <machine_set_name> \ -n openshift-cluster-api- The original example value of
2.
- The original example value of
-
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 machines.cluster.x-k8s.io <machine_name_updated_1> \ -n openshift-cluster-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.cluster.x-k8s.io \ -n openshift-cluster-api \ cluster.x-k8s.io/set-name=<machine_set_name>Example output while deletion is in progress for an AWS clusterNAME CLUSTER NODENAME PROVIDERID PHASE AGE VERSION <machine_name_original_1> <cluster_name> <original_1_ip>.<region>.compute.internal aws:///us-east-2a/i-04e7b2cbd61fd2075 Running 18m <machine_name_original_2> <cluster_name> <original_2_ip>.<region>.compute.internal aws:///us-east-2a/i-04e7b2cbd61fd2075 Running 18m <machine_name_updated_1> <cluster_name> <updated_1_ip>.<region>.compute.internal aws:///us-east-2a/i-04e7b2cbd61fd2075 Running 18m <machine_name_updated_2> <cluster_name> <updated_2_ip>.<region>.compute.internal aws:///us-east-2a/i-04e7b2cbd61fd2075 Running 18mExample output when deletion is complete for an AWS clusterNAME CLUSTER NODENAME PROVIDERID PHASE AGE VERSION <machine_name_updated_1> <cluster_name> <updated_1_ip>.<region>.compute.internal aws:///us-east-2a/i-04e7b2cbd61fd2075 Running 18m <machine_name_updated_2> <cluster_name> <updated_2_ip>.<region>.compute.internal aws:///us-east-2a/i-04e7b2cbd61fd2075 Running 18m
-
Sample YAML for a Cluster API compute machine set resource on Amazon Web Services
-
Sample YAML for a Cluster API compute machine set resource on Google Cloud
-
Sample YAML for a Cluster API compute machine set resource on Microsoft Azure
-
Sample YAML for a Cluster API compute machine set resource on RHOSP
-
Sample YAML for a Cluster API compute machine set resource on VMware vSphere