1.10. クラスター API


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

1.10.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 を指している必要があります。
  • *.apps.<cluster_name>.<base_domain> のアプリケーションベースドメインは、Ingress 仮想 IP の静的 IP アドレスを指している必要があります。
  • クラスターの内部 API エンドポイント api-int.<baseDomain> が必要です。

1.10.1.1. Cluster API を使用したワークロードのプロビジョニング

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

    oc edit multiclusterengines.multicluster.openshift.io -n multicluster-engine
    Copy to Clipboard Toggle word wrap
  2. .spec.overrides で、assisted-service コンポーネント、cluster-api-provider-metal3-preview コンポーネント、cluster-api-provider-openshift-assisted-preview コンポーネントを enabled: true に設定します。次の configOverrides 値を参照してください。

        - configOverrides: {}
          enabled: true
          name: assisted-service
        - configOverrides: {}
          enabled: true
          name: cluster-api
    ...
        - configOverrides: {}
          enabled: true
          name: cluster-api-provider-metal3-preview
        - configOverrides: {}
          enabled: true
          name: cluster-api-provider-openshift-assisted-preview
    Copy to Clipboard Toggle word wrap
  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: 
    1
    
        apiVersion: controlplane.cluster.x-k8s.io/v1alpha2
        kind: OpenshiftAssistedControlPlane
        name:  <cluster-name>
        namespace:  <cluster-namespace>
      infrastructureRef: 
    2
    
        apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
        kind: Metal3Cluster
        name: <cluster-name>
        namespace: <cluster-namespace>
    Copy to Clipboard Toggle word wrap
    1
    OpenshiftAssistedControlPlane はコントロールプレーンです。
    2
    Metal3Cluster はインフラストラクチャーです。
  5. 以下のコマンドを実行して YAML コンテンツを適用します。

    oc apply -f <filename>.yaml
    Copy to Clipboard Toggle word wrap
  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 }}" 
    1
    
        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 }}" 
    2
    
      machineTemplate:
        infrastructureRef:
          apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
          kind: Metal3MachineTemplate
          name: <cluster-name-control-plane>
          namespace: <cluster-namespace>
      replicas: 3
    Copy to Clipboard Toggle word wrap

    <1>`.spec.openshiftAssistedConfigSpec.sshAuthorizedKey` は、ブート (discovery とも呼ばれる) フェーズでノードにアクセスするために使用されます。<2>`.spec.config.sshAuthorizedKey` は、プロビジョニングされた OpenShift Container Platform ノードにアクセスするために使用されます。

  7. YAML ファイルを適用します。以下のコマンドを実行します。

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

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

    oc apply -f pull-secret.yaml
    Copy to Clipboard Toggle word wrap
  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 
    1
    
        port: 6443
      noCloudProvider: true
    Copy to Clipboard Toggle word wrap
    1
    host は、Cluster リソースの clusterName を持つ <clusterName>.<baseDomain>* 値であり、baseDomainOpenshiftAssistedControlPlane リソースで定義されます。
  12. ファイルを適用します。以下のコマンドを実行します。

    oc apply -f <filename>.yaml
    Copy to Clipboard Toggle word wrap
  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: 
    1
    
            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> 
    2
    Copy to Clipboard Toggle word wrap
    1
    イメージは、distributionVersion 値と OpenShift Container Platform Releases のバージョンと一致します。
    2
    clusterNameCluster リソースと同じ値に設定します。
  14. ファイルを適用します。以下のコマンドを実行します。

    oc apply -f <filename>.yaml
    Copy to Clipboard Toggle word wrap
  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: 
    2
    
            name: <cluster-name-workers-2>
            apiVersion: infrastructure.cluster.x-k8s.io/v1alpha3
            kind: Metal3MachineTemplate
    Copy to Clipboard Toggle word wrap
    1
    ブートストラップ設定は、インストールに関する次のリソースでも参照されます。
    2
    インフラストラクチャー参照は、プロビジョニングするリソースを参照します。
  16. ファイルを適用します。以下のコマンドを実行します。

    oc apply -f <filename>.yaml
    Copy to Clipboard Toggle word wrap
  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}"'
    1
    
          sshAuthorizedKey: "{{ ssh_authorized_key }}" 
    2
    Copy to Clipboard Toggle word wrap
    1
    kubeletExtraLabels は、この値から変更できません。
    2
    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>
    Copy to Clipboard Toggle word wrap
  19. 次のコマンドを実行して、YAML ファイルを保存し、クラスターをプロビジョニングします。

    oc apply -f <filename>.yaml
    Copy to Clipboard Toggle word wrap
  20. クラスターのプロビジョニングステータスを確認します。

    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
      Copy to Clipboard Toggle word wrap
    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
      Copy to Clipboard Toggle word wrap
    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
      Copy to Clipboard Toggle word wrap
    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
      Copy to Clipboard Toggle word wrap
    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
    Copy to Clipboard Toggle word wrap
  21. クラスターにアクセスします。

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

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

詳細情報

試用、購入および販売

コミュニティー

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

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

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

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

会社概要

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

Theme

© 2025 Red Hat