11.2. Getting started with the Cluster API
The Machine API and Cluster API are distinct API groups that have similar resources. You can use these API groups to automate the management of infrastructure resources on your OpenShift Container Platform cluster.
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.
When you install a standard OpenShift Container Platform cluster that has three control plane nodes, three compute nodes, and uses the default configuration options, the installation program provisions the following infrastructure resources in the openshift-machine-api namespace
- One control plane machine set that manages three control plane machines.
- One or more compute machine sets that manage three compute machines.
- One machine health check that manages spot instances.
When you install a cluster that supports managing infrastructure resources with the Cluster API, the installation program provisions the following resources in the openshift-cluster-api namespace:
- One cluster resource.
- One provider-specific infrastructure cluster resource.
On clusters that support migrating Machine API resources to Cluster API resources, a two-way synchronization controller creates these primary resources automatically. For more information, see Migrating Machine API resources to Cluster API resources.
11.2.1. Creating the Cluster API primary resources 링크 복사링크가 클립보드에 복사되었습니다!
For clusters that do not support migrating Machine API resources to Cluster API resources, you must manually create the following Cluster API resources in the openshift-cluster-api namespace:
- One or more machine templates that correspond to compute machine sets.
- One or more compute machine sets that manage three compute machines.
11.2.1.1. Creating a Cluster API machine template 링크 복사링크가 클립보드에 복사되었습니다!
You can create a provider-specific machine template resource by creating a YAML manifest file and applying it with the OpenShift CLI (oc).
Prerequisites
- You have deployed an OpenShift Container Platform cluster.
- You have enabled the use of the Cluster API.
-
You have access to the cluster using an account with
cluster-adminpermissions. -
You have installed the OpenShift CLI (
oc).
Procedure
Create a YAML file similar to the following. This procedure uses
<machine_template_resource_file>.yamlas an example file name.apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: <machine_template_kind>1 metadata: name: <template_name>2 namespace: openshift-cluster-api spec: template: spec:3 - 1
- Specify the machine template kind. This value must match the value for your platform. The following values are valid:
Expand Cluster infrastructure provider Value Amazon Web Services (AWS)
AWSMachineTemplateGoogle Cloud
GCPMachineTemplateMicrosoft Azure
AzureMachineTemplateRed Hat OpenStack Platform (RHOSP)
OpenStackMachineTemplateVMware vSphere
VSphereMachineTemplateBare metal
Metal3MachineTemplate - 2
- Specify a name for the machine template.
- 3
- Specify the details for your environment. These parameters are provider specific. For more information, see the sample Cluster API machine template YAML for your provider.
Create the machine template CR by running the following command:
$ oc create -f <machine_template_resource_file>.yaml
Verification
Confirm that the machine template CR is created by running the following command:
$ oc get <machine_template_kind> -n openshift-cluster-apiwhere
<machine_template_kind>is the value that corresponds to your platform.Example output
NAME AGE <template_name> 77m
11.2.1.2. Creating a Cluster API compute machine set 링크 복사링크가 클립보드에 복사되었습니다!
You can create compute machine sets that use the Cluster API to dynamically manage the machine compute resources for specific workloads of your choice.
Prerequisites
- You have deployed an OpenShift Container Platform cluster.
- You have enabled the use of the Cluster API.
-
You have access to the cluster using an account with
cluster-adminpermissions. -
You have installed the OpenShift CLI (
oc). - You have created the machine template resource.
Procedure
Create a YAML file similar to the following. This procedure uses
<machine_set_resource_file>.yamlas an example file name.apiVersion: cluster.x-k8s.io/v1beta1 kind: MachineSet metadata: name: <machine_set_name>1 namespace: openshift-cluster-api spec: clusterName: <cluster_name>2 replicas: 1 selector: matchLabels: test: example template: metadata: labels: test: example spec:3 # ...- 1
- Specify a name for the compute machine set. The cluster ID, machine role, and region form a typical pattern for this value in the following format:
<cluster_name>-<role>-<region>. - 2
- Specify the name of the cluster. Obtain the value of the cluster ID by running the following command:
$ oc get infrastructure cluster \ -o jsonpath='{.status.infrastructureName}' - 3
- Specify the details for your environment. These parameters are provider specific. For more information, see the sample Cluster API compute machine set YAML for your provider.
Create the compute machine set CR by running the following command:
$ oc create -f <machine_set_resource_file>.yamlConfirm that the compute machine set CR is created by running the following command:
$ oc get machineset.cluster.x-k8s.io -n openshift-cluster-apiExample output
NAME CLUSTER REPLICAS READY AVAILABLE AGE VERSION <machine_set_name> <cluster_name> 1 1 1 17mWhen the new compute machine set is available, the
REPLICASandAVAILABLEvalues match. If the compute machine set is not available, wait a few minutes and run the command again.
Verification
To verify that the compute machine set is creating machines according to your required configuration, review the lists of machines and nodes in the cluster by running the following commands:
View the list of Cluster API machines:
$ oc get machine.cluster.x-k8s.io -n openshift-cluster-apiExample output
NAME CLUSTER NODENAME PROVIDERID PHASE AGE VERSION <machine_set_name>-<string_id> <cluster_name> <ip_address>.<region>.compute.internal <provider_id> Running 8m23sView the list of nodes:
$ oc get nodeExample output
NAME STATUS ROLES AGE VERSION <ip_address_1>.<region>.compute.internal Ready worker 5h14m v1.28.5 <ip_address_2>.<region>.compute.internal Ready master 5h19m v1.28.5 <ip_address_3>.<region>.compute.internal Ready worker 7m v1.28.5