2.4.10. 既存の OpenShift Container Platform クラスターへの GPU ノードの追加


デフォルトのコンピュートマシンセット設定をコピーして変更することで、Google Cloud プロバイダー向けに GPU 対応のマシンセットとマシンを作成できます。これは、ハードウェアアクセラレーションを必要とする計算負荷の高いワークロードを支援します。

次の表は、検証済みのインスタンスタイプを示しています。

Expand
インスタンスタイプNVIDIA GPU アクセラレーターGPU の最大数アーキテクチャー

a2-highgpu-1g

A100

1

x86

n1-standard-4

T4

1

x86

手順

  1. 既存の MachineSet 設定のコピーを作成します。
  2. 新しいコピーで、metadata.namemachine.openshift.io/cluster-api-machineset の両方のインスタンスで、マシンセットの name を変更します。
  3. インスタンスタイプを変更して、新しくコピーした MachineSet 設定に次の 2 行を追加します。

    machineType: a2-highgpu-1g
    onHostMaintenance: Terminate

    a2-highgpu-1g.json ファイルの例

    {
        "apiVersion": "machine.openshift.io/v1beta1",
        "kind": "MachineSet",
        "metadata": {
            "annotations": {
                "machine.openshift.io/GPU": "0",
                "machine.openshift.io/memoryMb": "16384",
                "machine.openshift.io/vCPU": "4"
            },
            "creationTimestamp": "2023-01-13T17:11:02Z",
            "generation": 1,
            "labels": {
                "machine.openshift.io/cluster-api-cluster": "myclustername-2pt9p"
            },
            "name": "myclustername-2pt9p-worker-gpu-a",
            "namespace": "openshift-machine-api",
            "resourceVersion": "20185",
            "uid": "2daf4712-733e-4399-b4b4-d43cb1ed32bd"
        },
        "spec": {
            "replicas": 1,
            "selector": {
                "matchLabels": {
                    "machine.openshift.io/cluster-api-cluster": "myclustername-2pt9p",
                    "machine.openshift.io/cluster-api-machineset": "myclustername-2pt9p-worker-gpu-a"
                }
            },
            "template": {
                "metadata": {
                    "labels": {
                        "machine.openshift.io/cluster-api-cluster": "myclustername-2pt9p",
                        "machine.openshift.io/cluster-api-machine-role": "worker",
                        "machine.openshift.io/cluster-api-machine-type": "worker",
                        "machine.openshift.io/cluster-api-machineset": "myclustername-2pt9p-worker-gpu-a"
                    }
                },
                "spec": {
                    "lifecycleHooks": {},
                    "metadata": {},
                    "providerSpec": {
                        "value": {
                            "apiVersion": "machine.openshift.io/v1beta1",
                            "canIPForward": false,
                            "credentialsSecret": {
                                "name": "gcp-cloud-credentials"
                            },
                            "deletionProtection": false,
                            "disks": [
                                {
                                    "autoDelete": true,
                                    "boot": true,
                                    "image": "projects/rhcos-cloud/global/images/rhcos-412-86-202212081411-0-gcp-x86-64",
                                    "labels": null,
                                    "sizeGb": 128,
                                    "type": "pd-ssd"
                                }
                            ],
                            "kind": "GCPMachineProviderSpec",
                            "machineType": "a2-highgpu-1g",
                            "onHostMaintenance": "Terminate",
                            "metadata": {
                                "creationTimestamp": null
                            },
                            "networkInterfaces": [
                                {
                                    "network": "myclustername-2pt9p-network",
                                    "subnetwork": "myclustername-2pt9p-worker-subnet"
                                }
                            ],
                            "preemptible": true,
                            "projectID": "myteam",
                            "region": "us-central1",
                            "serviceAccounts": [
                                {
                                    "email": "myclustername-2pt9p-w@myteam.iam.gserviceaccount.com",
                                    "scopes": [
                                        "https://www.googleapis.com/auth/cloud-platform"
                                    ]
                                }
                            ],
                            "tags": [
                                "myclustername-2pt9p-worker"
                            ],
                            "userDataSecret": {
                                "name": "worker-user-data"
                            },
                            "zone": "us-central1-a"
                        }
                    }
                }
            }
        },
        "status": {
            "availableReplicas": 1,
            "fullyLabeledReplicas": 1,
            "observedGeneration": 1,
            "readyReplicas": 1,
            "replicas": 1
        }
    }

  4. 次のコマンドを実行して、既存のノード、マシン、およびマシンセットを表示します。各ノードは、特定の Google Cloud リージョンと OpenShift Container Platform ロールを持つマシン定義のインスタンスであることに注意してください。

    $ oc get nodes

    出力例

    NAME                                                             STATUS     ROLES                  AGE     VERSION
    myclustername-2pt9p-master-0.c.openshift-qe.internal             Ready      control-plane,master   8h      v1.33.4
    myclustername-2pt9p-master-1.c.openshift-qe.internal             Ready      control-plane,master   8h      v1.33.4
    myclustername-2pt9p-master-2.c.openshift-qe.internal             Ready      control-plane,master   8h      v1.33.4
    myclustername-2pt9p-worker-a-mxtnz.c.openshift-qe.internal       Ready      worker                 8h      v1.33.4
    myclustername-2pt9p-worker-b-9pzzn.c.openshift-qe.internal       Ready      worker                 8h      v1.33.4
    myclustername-2pt9p-worker-c-6pbg6.c.openshift-qe.internal       Ready      worker                 8h      v1.33.4
    myclustername-2pt9p-worker-gpu-a-wxcr6.c.openshift-qe.internal   Ready      worker                 4h35m   v1.33.4

  5. 次のコマンドを実行して、openshift-machine-api namespace に存在するマシンとマシンセットを表示します。各コンピュートマシンセットは、Google Cloud リージョン内の異なるアベイラビリティーゾーンに関連付けられています。インストールプログラムは、コンピュートマシンをアベイラビリティーゾーン間で自動的に負荷分散します。

    $ oc get machinesets -n openshift-machine-api

    出力例

    NAME                               DESIRED   CURRENT   READY   AVAILABLE   AGE
    myclustername-2pt9p-worker-a       1         1         1       1           8h
    myclustername-2pt9p-worker-b       1         1         1       1           8h
    myclustername-2pt9p-worker-c       1         1                             8h
    myclustername-2pt9p-worker-f       0         0                             8h

  6. 次のコマンドを実行して、openshift-machine-api namespace に存在するマシンを表示します。セットごとに設定できるコンピュートマシンは 1 つだけですが、コンピュートマシンセットをスケーリングして、特定のリージョンとゾーンにノードを追加することはできます。

    $ oc get machines -n openshift-machine-api | grep worker

    出力例

    myclustername-2pt9p-worker-a-mxtnz       Running   n2-standard-4   us-central1   us-central1-a   8h
    myclustername-2pt9p-worker-b-9pzzn       Running   n2-standard-4   us-central1   us-central1-b   8h
    myclustername-2pt9p-worker-c-6pbg6       Running   n2-standard-4   us-central1   us-central1-c   8h

  7. 次のコマンドを実行して、既存のコンピュート MachineSet 定義のいずれかのコピーを作成し、結果を JSON ファイルに出力します。これは、GPU 対応のコンピュートマシンセット定義の基礎となります。

    $ oc get machineset myclustername-2pt9p-worker-a -n openshift-machine-api -o json  > <output_file.json>
  8. JSON ファイルを編集し、新しい MachineSet 定義に次の変更を加えます。

    • サブストリング gpumetadata.namemachine.openshift.io/cluster-api-machineset の両方のインスタンスに挿入し、マシンセット name を変更します。
    • 新しい MachineSet 定義の machineType を、NVIDIA A100 GPU を含む a2-highgpu-1g に変更します。

      jq .spec.template.spec.providerSpec.value.machineType ocp_4.20_machineset-a2-highgpu-1g.json
      
      "a2-highgpu-1g"

      <output_file.json> ファイルは ocp_4.20_machineset-a2-highgpu-1g.json として保存されます。

  9. ocp_4.20_machineset-a2-highgpu-1g.json の次のフィールドを更新します。

    • .metadata.namegpu を含む名前に変更します。
    • .spec.selector.matchLabels["machine.openshift.io/cluster-api-machineset"] を変更して新しい .metadata.name に一致させます。
    • .spec.template.metadata.labels["machine.openshift.io/cluster-api-machineset"] を変更して新しい .metadata.name に一致させます。
    • .spec.template.spec.providerSpec.value.MachineTypea2-highgpu-1g に変更します。
    • machineType の下に次の行を追加します: `"onHostMaintenance": "Terminate"。以下に例を示します。

      "machineType": "a2-highgpu-1g",
      "onHostMaintenance": "Terminate",
  10. 変更を確認するには、次のコマンドを実行して、元のコンピュート定義と新しい GPU 対応ノード定義の diff を実行します。

    $ oc get machineset/myclustername-2pt9p-worker-a -n openshift-machine-api -o json | diff ocp_4.20_machineset-a2-highgpu-1g.json -

    出力例

    15c15
    <         "name": "myclustername-2pt9p-worker-gpu-a",
    ---
    >         "name": "myclustername-2pt9p-worker-a",
    25c25
    <                 "machine.openshift.io/cluster-api-machineset": "myclustername-2pt9p-worker-gpu-a"
    ---
    >                 "machine.openshift.io/cluster-api-machineset": "myclustername-2pt9p-worker-a"
    34c34
    <                     "machine.openshift.io/cluster-api-machineset": "myclustername-2pt9p-worker-gpu-a"
    ---
    >                     "machine.openshift.io/cluster-api-machineset": "myclustername-2pt9p-worker-a"
    59,60c59
    <                         "machineType": "a2-highgpu-1g",
    <                         "onHostMaintenance": "Terminate",
    ---
    >                         "machineType": "n2-standard-4",

  11. 次のコマンドを実行して、定義ファイルから GPU 対応のコンピュートマシンセットを作成します。

    $ oc create -f ocp_4.20_machineset-a2-highgpu-1g.json

    出力例

    machineset.machine.openshift.io/myclustername-2pt9p-worker-gpu-a created

検証

  1. 次のコマンドを実行して、作成したマシンセットを表示します。

    $ oc -n openshift-machine-api get machinesets | grep gpu

    MachineSet の レプリカ数は 1 に設定されているため、新しい Machine オブジェクトが自動的に作成されます。

    出力例

    myclustername-2pt9p-worker-gpu-a   1         1         1       1           5h24m

  2. 次のコマンドを実行して、マシンセットが作成した Machine オブジェクトを表示します。

    $ oc -n openshift-machine-api get machines | grep gpu

    出力例

    myclustername-2pt9p-worker-gpu-a-wxcr6   Running   a2-highgpu-1g   us-central1   us-central1-a   5h25m

注記

ノードの namespace を指定する必要がないことに注意してください。ノード定義はクラスタースコープ指定されています。

Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

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

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

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

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

会社概要

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

Theme

© 2026 Red Hat
トップに戻る