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-admin permissions.
  • You have installed the OpenShift CLI (oc).

Procedure

  1. Create a YAML file similar to the following. This procedure uses <machine_template_resource_file>.yaml as 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 providerValue

    Amazon Web Services (AWS)

    AWSMachineTemplate

    Google Cloud

    GCPMachineTemplate

    Microsoft Azure

    AzureMachineTemplate

    Red Hat OpenStack Platform (RHOSP)

    OpenStackMachineTemplate

    VMware vSphere

    VSphereMachineTemplate

    Bare 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.
  2. 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-api

    where <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-admin permissions.
  • You have installed the OpenShift CLI (oc).
  • You have created the machine template resource.

Procedure

  1. Create a YAML file similar to the following. This procedure uses <machine_set_resource_file>.yaml as 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.
  2. Create the compute machine set CR by running the following command:

    $ oc create -f <machine_set_resource_file>.yaml
  3. Confirm that the compute machine set CR is created by running the following command:

    $ oc get machineset.cluster.x-k8s.io -n openshift-cluster-api

    Example output

    NAME                 CLUSTER          REPLICAS   READY   AVAILABLE   AGE   VERSION
    <machine_set_name>   <cluster_name>   1          1       1           17m

    When the new compute machine set is available, the REPLICAS and AVAILABLE values 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-api

      Example output

      NAME                             CLUSTER          NODENAME                                 PROVIDERID      PHASE     AGE     VERSION
      <machine_set_name>-<string_id>   <cluster_name>   <ip_address>.<region>.compute.internal   <provider_id>   Running   8m23s

    • View the list of nodes:

      $ oc get node

      Example 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

Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 문서 정보

Legal Notice

Theme

© 2026 Red Hat
맨 위로 이동