2.4.10. 既存の OpenShift Container Platform クラスターへの GPU ノードの追加
デフォルトのコンピュートマシンセット設定をコピーして変更することで、Google Cloud プロバイダー向けに GPU 対応のマシンセットとマシンを作成できます。これは、ハードウェアアクセラレーションを必要とする計算負荷の高いワークロードを支援します。
次の表は、検証済みのインスタンスタイプを示しています。
| インスタンスタイプ | NVIDIA GPU アクセラレーター | GPU の最大数 | アーキテクチャー |
|---|---|---|---|
|
| A100 | 1 | x86 |
|
| T4 | 1 | x86 |
手順
-
既存の
MachineSet設定のコピーを作成します。 -
新しいコピーで、
metadata.nameとmachine.openshift.io/cluster-api-machinesetの両方のインスタンスで、マシンセットのnameを変更します。 インスタンスタイプを変更して、新しくコピーした
MachineSet設定に次の 2 行を追加します。machineType: a2-highgpu-1g onHostMaintenance: Terminatea2-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 } }次のコマンドを実行して、既存のノード、マシン、およびマシンセットを表示します。各ノードは、特定の 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次のコマンドを実行して、
openshift-machine-apinamespace に存在するマシンとマシンセットを表示します。各コンピュートマシンセットは、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次のコマンドを実行して、
openshift-machine-apinamespace に存在するマシンを表示します。セットごとに設定できるコンピュートマシンは 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次のコマンドを実行して、既存のコンピュート
MachineSet定義のいずれかのコピーを作成し、結果を JSON ファイルに出力します。これは、GPU 対応のコンピュートマシンセット定義の基礎となります。$ oc get machineset myclustername-2pt9p-worker-a -n openshift-machine-api -o json > <output_file.json>JSON ファイルを編集し、新しい
MachineSet定義に次の変更を加えます。-
サブストリング
gpuをmetadata.nameとmachine.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として保存されます。
-
サブストリング
ocp_4.20_machineset-a2-highgpu-1g.jsonの次のフィールドを更新します。-
.metadata.nameをgpuを含む名前に変更します。 -
.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.MachineTypeをa2-highgpu-1gに変更します。 machineTypeの下に次の行を追加します: `"onHostMaintenance": "Terminate"。以下に例を示します。"machineType": "a2-highgpu-1g", "onHostMaintenance": "Terminate",
-
変更を確認するには、次のコマンドを実行して、元のコンピュート定義と新しい 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",次のコマンドを実行して、定義ファイルから GPU 対応のコンピュートマシンセットを作成します。
$ oc create -f ocp_4.20_machineset-a2-highgpu-1g.json出力例
machineset.machine.openshift.io/myclustername-2pt9p-worker-gpu-a created
検証
次のコマンドを実行して、作成したマシンセットを表示します。
$ oc -n openshift-machine-api get machinesets | grep gpuMachineSet のレプリカ数は1に設定されているため、新しいMachineオブジェクトが自動的に作成されます。出力例
myclustername-2pt9p-worker-gpu-a 1 1 1 1 5h24m次のコマンドを実行して、マシンセットが作成した
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 を指定する必要がないことに注意してください。ノード定義はクラスタースコープ指定されています。