1.11. クラスター API


Cluster API は、Kubernetes クラスターのプロビジョニング、アップグレード、管理を簡素化する宣言型 API を提供します。multicluster engine Operator は、コアとなる Cluster API コンポーネントに加え、複数のインフラストラクチャープロバイダーとブートストラッププロバイダーをインストールすることで、さまざまなユースケースとプラットフォームをサポートします。スタンドアロンの multicluster engine Operator または Red Hat Advanced Cluster Management で Cluster API を使用する方法を説明します。次のプロセスを参照してください。

1.11.1. Cluster API を使用したマネージドクラスターのインストール

metal3 インフラストラクチャープロバイダーと OpenShift Container Platform 支援ブートストラップおよびコントロールプレーンプロバイダーを使用して、Cluster API を備えた OpenShift Container Platform マネージドクラスターをインストールできます。

  • ControlPlane リソースは、コントロールプレーンのプロパティーを定義します。
  • ClusterInfrastructure は、クラスターレベルのインフラストラクチャーの詳細を定義します。

前提条件

  • Red Hat Advanced Cluster Management インストールまたは multicluster engine Operator スタンドアロンインストールのいずれかからの MultiClusterEngine リソースが必要です。
  • api.<cluster_name>.<base_domain> の API ベースドメインは、静的 API 仮想 IP を指している必要があります。
  • 次のアプリケーションベースドメインは、Ingress VIP の静的 IP アドレスを指す必要があります。

    *.apps.<cluster_name>.<base_domain>
  • クラスターの内部 API エンドポイント api-int.<baseDomain> が必要です。
  • Cluster API Provider OpenShift Assisted には、以下のコンポーネントが必要です。

    • Cluster API: コアコンポーネントは、管理クラスター内で必要なカスタムリソース定義とコントローラーを提供します。
    • Assisted サービス: このサービスは、multicluster engine for Kubernetes Operator における Red Hat OpenShift のインフラストラクチャー Operator によってプロビジョニングされます。サービスが、アクセス可能で、かつ正常に動作していることを確認してください。
    • インフラストラクチャープロバイダー: cluster-api-provider-metal3 などのプロバイダーは、物理リソースまたは仮想リソースを管理します。

手順

  1. ワークロードをプロビジョニングするために必要なサービスを有効にします。デフォルトでは、assisted-service が有効になっています。デフォルトでは、cluster-api-provider-metal3cluster-api-provider-openshift-assisted は、無効になっています。3 つのサービスがすべて enabled: true であることを確認します。以下のコマンドを実行してリソースを編集します。

    oc edit multiclusterengines.multicluster.openshift.io -n multicluster-engine
  2. assisted-service コンポーネント、cluster-api-provider-metal3 コンポーネント、cluster-api-provider-openshift-assisted コンポーネントの .spec.overridesenabled: true を設定します。次の configOverrides 値を参照してください。

        - configOverrides: {}
          enabled: true
          name: assisted-service
        - configOverrides: {}
          enabled: true
          name: cluster-api
    ...
        - configOverrides: {}
          enabled: true
          name: cluster-api-provider-metal3
        - configOverrides: {}
          enabled: true
          name: cluster-api-provider-openshift-assisted
  3. Central Infrastructure Management サービスの有効化手順は central infrastructure management サービスの有効化 を参照してください。
  4. clusterNetwork 仕様、controlPlaneRef 仕様、および infrastructureRef 仕様を使用して Cluster リソースを設定します。次の Cluster リソースを参照してください。

    apiVersion: cluster.x-k8s.io/v1beta1
    kind: Cluster
    metadata:
      name: <cluster-name>
      namespace: <cluster-namespace>
    spec:
      clusterNetwork:
        pods:
          cidrBlocks:
            - 172.18.0.0/20
        services:
          cidrBlocks:
            - 10.96.0.0/12
      controlPlaneRef:
        apiVersion: controlplane.cluster.x-k8s.io/v1alpha2
        kind: OpenshiftAssistedControlPlane
        name:  <cluster-name>
        namespace:  <cluster-namespace>
      infrastructureRef:
        apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
        kind: Metal3Cluster
        name: <cluster-name>
        namespace: <cluster-namespace>
    • controlPlaneRef.kind では、OpenshiftAssistedControlPlane がコントロールプレーンです。
    • infrastructureRef.kind では、Metal3Cluster がインフラストラクチャーです。
  5. 以下のコマンドを実行して YAML コンテンツを適用します。

    oc apply -f <filename>.yaml
  6. distributionVersionapiVIPs、および SSH キーを含む OpenshiftAssistedControlPlane リソースを設定します。distributionVersion フィールドに OpenShift Container Platform のバージョンを指定します。

    注記: distributionVersion の値は OpenShift Container Platform Releases のイメージと一致します。次の YAML リソースを参照してください。

    apiVersion: controlplane.cluster.x-k8s.io/v1alpha2
    kind: OpenshiftAssistedControlPlane
    metadata:
      name: <cluster-name>
      namespace: <cluster-namespace>
      annotations: {}
    spec:
      openshiftAssistedConfigSpec:
        sshAuthorizedKey: "{{ ssh_authorized_key }}"
        nodeRegistration:
          kubeletExtraLabels:
          - 'metal3.io/uuid="${METADATA_UUID}"'
      distributionVersion: <4.x.0>
      config:
        apiVIPs:
        - 192.168.222.40
        ingressVIPs:
        - 192.168.222.41
        baseDomain: lab.home
        pullSecretRef:
          name: "pull-secret"
        sshAuthorizedKey: "{{ ssh_authorized_key }}" 
    1
    
      machineTemplate:
        infrastructureRef:
          apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
          kind: Metal3MachineTemplate
          name: <cluster-name-control-plane>
          namespace: <cluster-namespace>
      replicas: 3
    • .spec.openshiftAssistedConfigSpec.sshAuthorizedKey は、ブート フェーズ (検出 フェーズとも呼ばれる) でノードにアクセスする場合に使用されます。
    • .spec.config.sshAuthorizedKey は、プロビジョニングされた OpenShift Container Platform ノードにアクセスするために使用されます。
  7. YAML ファイルを適用します。以下のコマンドを実行します。

    oc apply -f <filename>.yaml
  8. プルシークレットがない場合は、クラスターがコンテナーレジストリーからイメージをプルできるように、プルシークレットを作成する必要があります。プルシークレットを作成するには、次の手順を実行します。
  9. イメージをプルするための YAML ファイルを作成します。pull-secret.yaml という名前のファイルの次の例を参照してください。

    apiVersion: v1
    kind: Secret
    metadata:
      name: pull-secret
      namespace: <cluster-namespace>
    data:
      .dockerconfigjson: <encoded_docker_configuration>
    type: kubernetes.io/dockerconfigjson
    • <cluster-namespace> 値がターゲットの namespace と一致していることを確認します。
    • <encoded_docker_configuration> の値として、base64 でエンコードされた設定ファイルを指定します。
  10. 次のコマンドを実行して、ファイルを適用します。

    oc apply -f pull-secret.yaml
  11. ベアメタル上のクラスターのデプロイメントに関連する情報が含まれる Metal3Cluster インフラストラクチャーリソースを設定します。

    apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
    kind: Metal3Cluster
    metadata:
      name: <cluster-name>
      namespace: <cluster-namespace>
    spec:
      controlPlaneEndpoint:
        host: <cluster-name>.lab.home
        port: 6443
      noCloudProvider: true
    • host は、Cluster リソースの clusterName を持つ <clusterName>.<baseDomain>* 値であり、baseDomainOpenshiftAssistedControlPlane リソースで定義されます。
  12. ファイルを適用します。以下のコマンドを実行します。

    oc apply -f <filename>.yaml
  13. OpenshiftAssistedControlPlane リソースから参照されるコントロールプレーンノードの Metal3MachineTemplate リソースを設定します。以下の YAML 例を参照してください。

    apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
    kind: Metal3MachineTemplate
    metadata:
      name: <cluster-name>
      namespace: <cluster-namespace>
    spec:
      nodeReuse: false
      template:
        spec:
          automatedCleaningMode: disabled
          dataTemplate:
            name: <cluster-name-template>
          image:
            checksum: https://mirror.openshift.com/pub/openshift-v4/x86_64/dependencies/rhcos/4.19/4.19.0/sha256sum.txt
            checksumType: sha256
            url: https://mirror.openshift.com/pub/openshift-v4/x86_64/dependencies/rhcos/4.19/4.19.0/rhcos-4.19.0-x86_64-nutanix.x86_64.qcow2
            format: qcow2
    ---
    apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
    kind: Metal3DataTemplate
    metadata:
       name: <cluster-name-template>
       namespace: <cluster-namespace>
    spec:
       clusterName: <cluster-name>
    • spec.template.spec.image は、distributionVersion の値と、OpenShift Container Platform Releases のバージョンに一致します。
    • <cluster-name>Cluster リソースと同じ値に設定します。
  14. ファイルを適用します。以下のコマンドを実行します。

    oc apply -f <filename>.yaml
  15. Metal3MachineTemplate を参照する MachineDeployment リソースを使用してワーカーノードを設定します。以下は、YAML の例です。

    apiVersion: cluster.x-k8s.io/v1beta1
    kind: MachineDeployment
    metadata:
      name: <cluster-name-worker>
      namespace: <cluster-namespace>
      labels:
        cluster.x-k8s.io/cluster-name: <cluster-name>
    spec:
      clusterName: <cluster-name>
      replicas: 2
      selector:
        matchLabels:
          cluster.x-k8s.io/cluster-name: <cluster-name>
      template:
        metadata:
          labels:
            cluster.x-k8s.io/cluster-name: <cluster-name>
        spec:
          clusterName: <cluster-name>
          bootstrap: 
    1
    
            configRef:
              name: <cluster-name-worker>
              apiVersion: bootstrap.cluster.x-k8s.io/v1alpha1
              kind: OpenshiftAssistedConfigTemplate
          infrastructureRef:
            name: <cluster-name-workers-2>
            apiVersion: infrastructure.cluster.x-k8s.io/v1alpha3
            kind: Metal3MachineTemplate
    • spec.bootstrap 設定は、インストールに関する次のリソースでも参照されます。
    • infrastructureRef 参照は、プロビジョニングするリソースを指します。
  16. ファイルを適用します。以下のコマンドを実行します。

    oc apply -f <filename>.yaml
  17. MachineDeployment で参照される OpenshiftAssistedConfigTemplate リソースを作成します。次の YAML はワーカーノードのブートストラップ設定を定義し、Assisted Installer を使用してノードを登録するために使用されます。

    apiVersion: bootstrap.cluster.x-k8s.io/v1alpha1
    kind: OpenshiftAssistedConfigTemplate
    metadata:
      name: <cluster-name-worker>
      namespace: <cluster-namespace>
      labels:
        cluster.x-k8s.io/cluster-name: cluster-name
    spec:
      template:
        spec:
          nodeRegistration:
            kubeletExtraLabels:
              - 'metal3.io/uuid="${METADATA_UUID}"'
          sshAuthorizedKey: "{{ ssh_authorized_key }}"
    • kubeletExtraLabels は、この値から変更できません。
    • sshAuthorizedKey フィールドにキーを入力します。
  18. MachineDeployment リソースで参照される Metal3MachineTemplate を作成します。以下の例を参照してください。

    apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
    kind: Metal3MachineTemplate
    metadata:
       name: <cluster-name-workers-2>
       namespace: <cluster-namespace>
    spec:
       nodeReuse: false
       template:
          spec:
             automatedCleaningMode: metadata
             dataTemplate:
                name: <cluster-name-workers-template>
          image:
            checksum: https://mirror.openshift.com/pub/openshift-v4/x86_64/dependencies/rhcos/4.19/4.19.0/sha256sum.txt
            checksumType: sha256
            url: https://mirror.openshift.com/pub/openshift-v4/x86_64/dependencies/rhcos/4.19/4.19.0/rhcos-4.19.0-x86_64-nutanix.x86_64.qcow2
            format: qcow2
    ---
    apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
    kind: Metal3DataTemplate
    metadata:
       name: <cluster-name-workers-template>
       namespace: <cluster-namespace>
    spec:
       clusterName: <cluster-name>
  19. 次のコマンドを実行して、YAML ファイルを保存し、クラスターをプロビジョニングします。

    oc apply -f <filename>.yaml

検証

  1. oc get cluster --namespace <cluster-namespace> <cluster-name> -o yaml を実行して、Cluster リソースのステータスを確認します。

    次の出力とステータスを参照してください。

    status:
      conditions:
      - lastTransitionTime: "2025-06-25T11:23:38Z"
        status: "True"
        type: Ready
      - lastTransitionTime: "2025-06-25T11:23:38Z"
        status: "True"
        type: ControlPlaneReady
      - lastTransitionTime: "2025-06-25T10:37:03Z"
        status: "True"
        type: InfrastructureReady
  2. oc get metal3cluster --namespace <cluster-namespace> <cluster-name> -o yaml コマンドを実行して、クラスターインフラストラクチャーのステータスを確認します。

    次の出力とステータスを参照してください。

    status:
      conditions:
      - lastTransitionTime: "2025-06-25T10:37:03Z"
        status: "True"
        type: Ready
      - lastTransitionTime: "2025-06-25T10:37:03Z"
        status: "True"
        type: BaremetalInfrastructureReady
  3. コントロールプレーンのステータスを確認するには、oc get openshiftassistedcontrolplane --namespace <cluster-namespace> <cluster-name> -o yaml コマンドを実行します。

    次の出力とステータスを参照してください。

    status:
      conditions:
      - lastTransitionTime: "2025-06-25T11:23:38Z"
        status: "True"
        type: Ready
      - lastTransitionTime: "2025-06-25T11:23:38Z"
        status: "True"
        type: ControlPlaneReady
      - lastTransitionTime: "2025-06-25T10:45:48Z"
        status: "True"
        type: KubeconfigAvailable
      - lastTransitionTime: "2025-06-25T10:38:25Z"
        status: "True"
        type: MachinesCreated
      - lastTransitionTime: "2025-06-25T11:10:54Z"
        status: "True"
        type: MachinesReady
      - lastTransitionTime: "2025-06-25T11:23:38Z"
        status: "True"
        type: UpgradeCompleted
  4. oc get machinedeployment --namespace <cluster-namespace> <cluster-name> -o yaml コマンドを実行して、マシンのデプロイメントのステータスを確認します。

    次の出力とステータスを参照してください。

    status:
      conditions:
      - lastTransitionTime: "2025-06-25T11:10:29Z"
        status: "True"
        type: Ready
      - lastTransitionTime: "2025-06-25T11:10:29Z"
        status: "True"
        type: Available
      - lastTransitionTime: "2025-06-25T11:10:29Z"
        status: "True"
        type: MachineSetReady
  5. kubectl get machine -l cluster.x-k8s.io/cluster-name=cluster-name -n test-capi -o yaml コマンドを実行して、マシンを確認します。

    次の出力とステータスを参照してください。

     status:
        conditions:
        - lastTransitionTime: "2025-06-25T11:09:57Z"
      	status: "True"
      	type: Ready
        - lastTransitionTime: "2025-06-25T10:38:20Z"
      	status: "True"
      	type: BootstrapReady
        - lastTransitionTime: "2025-06-25T11:09:57Z"
      	status: "True"
      	type: InfrastructureReady
        - lastTransitionTime: "2025-06-25T11:10:29Z"
      	status: "True"
      	type: NodeHealthy
  6. クラスターにアクセスします。

    1. kubeconfig ファイルを取得するには、次のコマンドを実行します。

      oc get secret -n test-capi  cluster-name-admin-kubeconfig -o json | jq -r .data.kubeconfig | base64 --decode > kubeconfig
    2. kubeconfig ファイルを使用してクラスターにアクセスするには、次のコマンドを実行します。
    export KUBECONFIG=$(realpath kubeconfig)
    oc get nodes
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

Red Hat ドキュメントについて

Legal Notice

Theme

© 2026 Red Hat
トップに戻る