2.3. Azure Stack Hub でコンピュートマシンセットを作成
Microsoft Azure Stack Hub 上の OpenShift Container Platform クラスターで特定の目的を果たすように異なるコンピュートマシンセットを作成することができます。たとえば、インフラストラクチャーマシンセットおよび関連マシンを作成して、サポートするワークロードを新しいマシンに移動できます。
高度なマシン管理およびスケーリング機能は、Machine API が動作しているクラスターでのみ使用できます。user-provisioned infrastructure を持つクラスターでは、Machine API を使用するために追加の検証と設定が必要です。
インフラストラクチャープラットフォームタイプが none
のクラスターでは、Machine API を使用できません。この制限は、クラスターに接続されている計算マシンが、この機能をサポートするプラットフォームにインストールされている場合でも適用されます。このパラメーターは、インストール後に変更することはできません。
クラスターのプラットフォームタイプを表示するには、以下のコマンドを実行します。
oc get infrastructure cluster -o jsonpath='{.status.platform}'
$ oc get infrastructure cluster -o jsonpath='{.status.platform}'
2.3.1. Azure Stack Hub 上のコンピュートマシンセットカスタムリソースのサンプル YAML
このサンプル YAML は、リージョンの 1
Microsoft Azure ゾーンで実行され、node-role.kubernetes.io/<role>: ""
というラベルの付けられたノードを作成するコンピュートマシンセットを定義します。
このサンプルでは、<infrastructure_id>
はクラスターのプロビジョニング時に設定したクラスター ID に基づくインフラストラクチャー ID であり、<role>
は追加するノードラベルです。
apiVersion: machine.openshift.io/v1beta1 kind: MachineSet metadata: labels: machine.openshift.io/cluster-api-cluster: <infrastructure_id> machine.openshift.io/cluster-api-machine-role: <role> machine.openshift.io/cluster-api-machine-type: <role> name: <infrastructure_id>-<role>-<region> namespace: openshift-machine-api spec: replicas: 1 selector: matchLabels: machine.openshift.io/cluster-api-cluster: <infrastructure_id> machine.openshift.io/cluster-api-machineset: <infrastructure_id>-<role>-<region> template: metadata: creationTimestamp: null labels: machine.openshift.io/cluster-api-cluster: <infrastructure_id> machine.openshift.io/cluster-api-machine-role: <role> machine.openshift.io/cluster-api-machine-type: <role> machine.openshift.io/cluster-api-machineset: <infrastructure_id>-<role>-<region> spec: metadata: creationTimestamp: null labels: node-role.kubernetes.io/<role>: "" providerSpec: value: apiVersion: machine.openshift.io/v1beta1 availabilitySet: <availability_set> credentialsSecret: name: azure-cloud-credentials namespace: openshift-machine-api image: offer: "" publisher: "" resourceID: /resourceGroups/<infrastructure_id>-rg/providers/Microsoft.Compute/images/<infrastructure_id> sku: "" version: "" internalLoadBalancer: "" kind: AzureMachineProviderSpec location: <region> managedIdentity: <infrastructure_id>-identity metadata: creationTimestamp: null natRule: null networkResourceGroup: "" osDisk: diskSizeGB: 128 managedDisk: storageAccountType: Premium_LRS osType: Linux publicIP: false publicLoadBalancer: "" resourceGroup: <infrastructure_id>-rg sshPrivateKey: "" sshPublicKey: "" subnet: <infrastructure_id>-<role>-subnet userDataSecret: name: worker-user-data vmSize: Standard_DS4_v2 vnet: <infrastructure_id>-vnet zone: "1"
apiVersion: machine.openshift.io/v1beta1
kind: MachineSet
metadata:
labels:
machine.openshift.io/cluster-api-cluster: <infrastructure_id>
machine.openshift.io/cluster-api-machine-role: <role>
machine.openshift.io/cluster-api-machine-type: <role>
name: <infrastructure_id>-<role>-<region>
namespace: openshift-machine-api
spec:
replicas: 1
selector:
matchLabels:
machine.openshift.io/cluster-api-cluster: <infrastructure_id>
machine.openshift.io/cluster-api-machineset: <infrastructure_id>-<role>-<region>
template:
metadata:
creationTimestamp: null
labels:
machine.openshift.io/cluster-api-cluster: <infrastructure_id>
machine.openshift.io/cluster-api-machine-role: <role>
machine.openshift.io/cluster-api-machine-type: <role>
machine.openshift.io/cluster-api-machineset: <infrastructure_id>-<role>-<region>
spec:
metadata:
creationTimestamp: null
labels:
node-role.kubernetes.io/<role>: ""
providerSpec:
value:
apiVersion: machine.openshift.io/v1beta1
availabilitySet: <availability_set>
credentialsSecret:
name: azure-cloud-credentials
namespace: openshift-machine-api
image:
offer: ""
publisher: ""
resourceID: /resourceGroups/<infrastructure_id>-rg/providers/Microsoft.Compute/images/<infrastructure_id>
sku: ""
version: ""
internalLoadBalancer: ""
kind: AzureMachineProviderSpec
location: <region>
managedIdentity: <infrastructure_id>-identity
metadata:
creationTimestamp: null
natRule: null
networkResourceGroup: ""
osDisk:
diskSizeGB: 128
managedDisk:
storageAccountType: Premium_LRS
osType: Linux
publicIP: false
publicLoadBalancer: ""
resourceGroup: <infrastructure_id>-rg
sshPrivateKey: ""
sshPublicKey: ""
subnet: <infrastructure_id>-<role>-subnet
userDataSecret:
name: worker-user-data
vmSize: Standard_DS4_v2
vnet: <infrastructure_id>-vnet
zone: "1"
- 1 5 7 13 15 16 17 20
- クラスターのプロビジョニング時に設定したクラスター ID を基にするインフラストラクチャー ID を指定します。OpenShift CLI がインストールされている場合は、以下のコマンドを実行してインフラストラクチャー ID を取得できます。
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get -o jsonpath='{.status.infrastructureName}{"\n"}' infrastructure cluster
$ oc get -o jsonpath='{.status.infrastructureName}{"\n"}' infrastructure cluster
以下のコマンドを実行してサブネットを取得できます。
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc -n openshift-machine-api \ -o jsonpath='{.spec.template.spec.providerSpec.value.subnet}{"\n"}' \ get machineset/<infrastructure_id>-worker-centralus1
$ oc -n openshift-machine-api \ -o jsonpath='{.spec.template.spec.providerSpec.value.subnet}{"\n"}' \ get machineset/<infrastructure_id>-worker-centralus1
以下のコマンドを実行して vnet を取得できます。
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc -n openshift-machine-api \ -o jsonpath='{.spec.template.spec.providerSpec.value.vnet}{"\n"}' \ get machineset/<infrastructure_id>-worker-centralus1
$ oc -n openshift-machine-api \ -o jsonpath='{.spec.template.spec.providerSpec.value.vnet}{"\n"}' \ get machineset/<infrastructure_id>-worker-centralus1
- 2 3 8 9 11 18 19
- 追加するノードラベルを指定します。
- 4 6 10
- インフラストラクチャー ID、ノードラベル、およびリージョンを指定します。
- 14
- マシンを配置するリージョンを指定します。
- 21
- マシンを配置するリージョン内のゾーンを指定します。リージョンがゾーンをサポートすることを確認してください。
- 12
- クラスターの可用性セットを指定します。
2.3.2. コンピュートマシンセットの作成
インストールプログラムによって作成されるコンピュートセットセットに加えて、独自のマシンセットを作成して、選択した特定のワークロードのマシンコンピューティングリソースを動的に管理できます。
前提条件
- OpenShift Container Platform クラスターをデプロイしている。
-
OpenShift CLI (
oc
) がインストールされている。 -
cluster-admin
パーミッションを持つユーザーとして、oc
にログインする。 - Azure Stack Hub コンピュートマシンをデプロイする可用性セットを作成します。
手順
コンピュートマシンセットのカスタムリソース (CR) サンプルを含む新しい YAML ファイルを作成し、
<file_name>.yaml
という名前を付けます。<availabilitySet>
、<clusterID>
、および<role>
パラメーター値を必ず設定してください。オプション: 特定のフィールドに設定する値がわからない場合は、クラスターから既存のコンピュートマシンセットを確認できます。
クラスター内のコンピュートマシンセットをリスト表示するには、次のコマンドを実行します。
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get machinesets -n openshift-machine-api
$ oc get machinesets -n openshift-machine-api
出力例
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NAME DESIRED CURRENT READY AVAILABLE AGE agl030519-vplxk-worker-us-east-1a 1 1 1 1 55m agl030519-vplxk-worker-us-east-1b 1 1 1 1 55m agl030519-vplxk-worker-us-east-1c 1 1 1 1 55m agl030519-vplxk-worker-us-east-1d 0 0 55m agl030519-vplxk-worker-us-east-1e 0 0 55m agl030519-vplxk-worker-us-east-1f 0 0 55m
NAME DESIRED CURRENT READY AVAILABLE AGE agl030519-vplxk-worker-us-east-1a 1 1 1 1 55m agl030519-vplxk-worker-us-east-1b 1 1 1 1 55m agl030519-vplxk-worker-us-east-1c 1 1 1 1 55m agl030519-vplxk-worker-us-east-1d 0 0 55m agl030519-vplxk-worker-us-east-1e 0 0 55m agl030519-vplxk-worker-us-east-1f 0 0 55m
特定のコンピュートマシンセットカスタムリソース (CR) 値を表示するには、以下のコマンドを実行します。
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get machineset <machineset_name> \ -n openshift-machine-api -o yaml
$ oc get machineset <machineset_name> \ -n openshift-machine-api -o yaml
出力例
Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: machine.openshift.io/v1beta1 kind: MachineSet metadata: labels: machine.openshift.io/cluster-api-cluster: <infrastructure_id> name: <infrastructure_id>-<role> namespace: openshift-machine-api spec: replicas: 1 selector: matchLabels: machine.openshift.io/cluster-api-cluster: <infrastructure_id> machine.openshift.io/cluster-api-machineset: <infrastructure_id>-<role> template: metadata: labels: machine.openshift.io/cluster-api-cluster: <infrastructure_id> machine.openshift.io/cluster-api-machine-role: <role> machine.openshift.io/cluster-api-machine-type: <role> machine.openshift.io/cluster-api-machineset: <infrastructure_id>-<role> spec: providerSpec: ...
apiVersion: machine.openshift.io/v1beta1 kind: MachineSet metadata: labels: machine.openshift.io/cluster-api-cluster: <infrastructure_id>
1 name: <infrastructure_id>-<role>
2 namespace: openshift-machine-api spec: replicas: 1 selector: matchLabels: machine.openshift.io/cluster-api-cluster: <infrastructure_id> machine.openshift.io/cluster-api-machineset: <infrastructure_id>-<role> template: metadata: labels: machine.openshift.io/cluster-api-cluster: <infrastructure_id> machine.openshift.io/cluster-api-machine-role: <role> machine.openshift.io/cluster-api-machine-type: <role> machine.openshift.io/cluster-api-machineset: <infrastructure_id>-<role> spec: providerSpec:
3 ...
次のコマンドを実行して
MachineSet
CR を作成します。Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc create -f <file_name>.yaml
$ oc create -f <file_name>.yaml
検証
次のコマンドを実行して、コンピュートマシンセットのリストを表示します。
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get machineset -n openshift-machine-api
$ oc get machineset -n openshift-machine-api
出力例
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NAME DESIRED CURRENT READY AVAILABLE AGE agl030519-vplxk-infra-us-east-1a 1 1 1 1 11m agl030519-vplxk-worker-us-east-1a 1 1 1 1 55m agl030519-vplxk-worker-us-east-1b 1 1 1 1 55m agl030519-vplxk-worker-us-east-1c 1 1 1 1 55m agl030519-vplxk-worker-us-east-1d 0 0 55m agl030519-vplxk-worker-us-east-1e 0 0 55m agl030519-vplxk-worker-us-east-1f 0 0 55m
NAME DESIRED CURRENT READY AVAILABLE AGE agl030519-vplxk-infra-us-east-1a 1 1 1 1 11m agl030519-vplxk-worker-us-east-1a 1 1 1 1 55m agl030519-vplxk-worker-us-east-1b 1 1 1 1 55m agl030519-vplxk-worker-us-east-1c 1 1 1 1 55m agl030519-vplxk-worker-us-east-1d 0 0 55m agl030519-vplxk-worker-us-east-1e 0 0 55m agl030519-vplxk-worker-us-east-1f 0 0 55m
新しいコンピュートマシンセットが利用可能になると、
DESIRED
とCURRENT
の値が一致します。コンピュートマシンセットが使用できない場合は、数分待ってからコマンドを再実行してください。
2.3.3. Cluster Autoscaler 用の GPU マシンセットのラベル付け
マシンセットラベルを使用すると、Cluster Autoscaler が GPU 対応ノードのデプロイに使用できるマシンを指定できます。
前提条件
- クラスターが Cluster Autoscaler を使用している。
手順
Cluster Autoscaler が GPU 対応ノードのデプロイに使用するマシンを作成するのに必要なマシンセットに、
cluster-api/accelerator
ラベルを追加します。Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: machine.openshift.io/v1beta1 kind: MachineSet metadata: name: machine-set-name spec: template: spec: metadata: labels: cluster-api/accelerator: nvidia-t4
apiVersion: machine.openshift.io/v1beta1 kind: MachineSet metadata: name: machine-set-name spec: template: spec: metadata: labels: cluster-api/accelerator: nvidia-t4
1 - 1
- 英数字、
-
、_
、.
で構成され、先頭と末尾が英数字であるラベルを指定します。たとえば、Nvidia T4 GPU を表すにはnvidia-t4
を使用し、A10G GPU を表すにはnvidia-a10g
を使用します。注記ClusterAutoscaler
CR のspec.resourceLimits.gpus.type
パラメーターにこのラベルの値を指定する必要があります。詳細は、「Cluster Autoscaler リソース定義」を参照してください。
2.3.4. Azure ブート診断の有効化
マシンセットが作成する Azure マシンで起動診断を有効にできます。
前提条件
- 既存の Microsoft Azure Stack Hub クラスターがある。
手順
ストレージタイプに適用可能な
diagnostics
設定を、マシンセット YAML ファイルのproviderSpec
フィールドに追加します。Azure Managed ストレージアカウントの場合:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow providerSpec: diagnostics: boot: storageAccountType: AzureManaged
providerSpec: diagnostics: boot: storageAccountType: AzureManaged
1 - 1
- Azure Managed ストレージアカウントを指定します。
Azure Unmanaged ストレージアカウントの場合:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow providerSpec: diagnostics: boot: storageAccountType: CustomerManaged customerManaged: storageAccountURI: https://<storage-account>.blob.core.windows.net
providerSpec: diagnostics: boot: storageAccountType: CustomerManaged
1 customerManaged: storageAccountURI: https://<storage-account>.blob.core.windows.net
2 注記Azure Blob Storage データサービスのみサポートされています。
検証
- Microsoft Azure ポータルで、マシンセットによってデプロイされたマシンの 起動診断 ページを確認し、マシンのシリアルログが表示されることを確認します。
2.3.5. マシンセットの顧客管理の暗号鍵の有効化
Azure に暗号化キーを指定して、停止中に管理ディスクのデータを暗号化できます。Machine API を使用すると、顧客管理の鍵によるサーバー側暗号化を有効にすることができます。
お客様が管理する鍵を使用するために、Azure Key Vault、ディスク暗号化セット、および暗号化キーが必要です。ディスク暗号化セットは、Cloud Credential Operator (CCO) がアクセス許可を付与したリソースグループに存在する必要があります。これがない場合は、ディスク暗号化セットで追加のリーダーロールを指定する必要があります。
前提条件
手順
マシンセット YAML ファイルの
providerSpec
フィールドでディスクの暗号化キーを設定します。以下に例を示します。Copy to Clipboard Copied! Toggle word wrap Toggle overflow providerSpec: value: osDisk: diskSizeGB: 128 managedDisk: diskEncryptionSet: id: /subscriptions/<subscription_id>/resourceGroups/<resource_group_name>/providers/Microsoft.Compute/diskEncryptionSets/<disk_encryption_set_name> storageAccountType: Premium_LRS
providerSpec: value: osDisk: diskSizeGB: 128 managedDisk: diskEncryptionSet: id: /subscriptions/<subscription_id>/resourceGroups/<resource_group_name>/providers/Microsoft.Compute/diskEncryptionSets/<disk_encryption_set_name> storageAccountType: Premium_LRS