6.2. 実稼働環境用のインフラストラクチャーマシンセットの作成
実稼働デプロイメントでは、インフラストラクチャーコンポーネントを保持するために 3 つ以上のマシンセットをデプロイします。ロギング集約ソリューションおよびサービスメッシュはどちらも Elasticsearch をデプロインし、Elasticsearch では複数の異なるノードにインストールされる 3 つのインスタンスが必要です。高可用性を確保するには、これらのノードを複数の異なるアベイラビリティーゾーンにデプロイします。各アベイラビリティーゾーンにそれぞれ異なるマシンセットが必要であるため、3 つ以上のマシンセットを作成します。
6.2.1. 異なるクラウドのマシンセットの作成
クラウドのサンプルマシンセットを使用します。
6.2.1.1. AWS 上のマシンセットカスタムリソースのサンプル YAML
このサンプル YAML は us-east-1a
Amazon Web Services (AWS) ゾーンで実行され、node-role.kubernetes.io/infra:""
というラベルが付けられたノードを作成するマシンセットを定義します。
このサンプルでは、<infrastructureID>
はクラスターのプロビジョニング時に設定したクラスター ID に基づくインフラストラクチャー ID であり、infra
は追加するノードラベルです。
apiVersion: machine.openshift.io/v1beta1 kind: MachineSet metadata: labels: machine.openshift.io/cluster-api-cluster: <infrastructureID> 1 name: <infrastructureID>-infra-<zone> 2 namespace: openshift-machine-api spec: replicas: 1 selector: matchLabels: machine.openshift.io/cluster-api-cluster: <infrastructureID> 3 machine.openshift.io/cluster-api-machineset: <infrastructureID>-infra-<zone> 4 template: metadata: labels: machine.openshift.io/cluster-api-cluster: <infrastructureID> 5 machine.openshift.io/cluster-api-machine-role: infra 6 machine.openshift.io/cluster-api-machine-type: infra 7 machine.openshift.io/cluster-api-machineset: <infrastructureID>-infra-<zone> 8 spec: metadata: labels: node-role.kubernetes.io/infra: "" 9 taints: 10 - key: node-role.kubernetes.io/infra effect: NoSchedule providerSpec: value: ami: id: ami-046fe691f52a953f9 11 apiVersion: awsproviderconfig.openshift.io/v1beta1 blockDevices: - ebs: iops: 0 volumeSize: 120 volumeType: gp2 credentialsSecret: name: aws-cloud-credentials deviceIndex: 0 iamInstanceProfile: id: <infrastructureID>-worker-profile 12 instanceType: m4.large kind: AWSMachineProviderConfig placement: availabilityZone: us-east-1a region: us-east-1 securityGroups: - filters: - name: tag:Name values: - <infrastructureID>-worker-sg 13 subnet: filters: - name: tag:Name values: - <infrastructureID>-private-us-east-1a 14 tags: - name: kubernetes.io/cluster/<infrastructureID> 15 value: owned userDataSecret: name: worker-user-data
- 1 3 5 12 13 14 15
- クラスターのプロビジョニング時に設定したクラスター ID を基にするインフラストラクチャー ID を指定します。OpenShift CLI がインストールされている場合は、以下のコマンドを実行してインフラストラクチャー ID を取得できます。
$ oc -n openshift-machine-api \ -o jsonpath='{.spec.template.spec.providerSpec.value.ami.id}{"\n"}' \ get machineset/<infrastructureID>-worker-us-east-1a
- 2 4 8
- インフラストラクチャー ID、
infra
ノードラベル、およびゾーンを指定します。 - 6 7 9
infra
ノードラベルを指定します。- 10
- ユーザーのワークロードが infra ノードにスケジュールされないようにテイントを指定します。
- 11
- OpenShift Container Platform ノードの AWS ゾーンに有効な Red Hat Enterprise Linux CoreOS (RHCOS) AMI を指定します。
AWS で実行されるマシンセットは保証されていない Spot インスタンス をサポートします。AWS の On-Demand インスタンスと比較すると、Spot インスタンスをより低い価格で使用することでコストを節約できます。MachineSet
YAML ファイルに spotMarketOptions
を追加して Configure Spot Instances を設定 します。
6.2.1.2. Azure 上のマシンセットのカスタムリソースのサンプル YAML
このサンプル YAML は、centralus
リージョンの 1
Microsoft Azure ゾーンで実行され、 node-role.kubernetes.io/infra: ""
というラベルの付けられたノードを作成するマシンセットを定義します。
このサンプルでは、<infrastructureID>
はクラスターのプロビジョニング時に設定したクラスター ID に基づくインフラストラクチャー ID であり、infra
は追加するノードラベルです。
apiVersion: machine.openshift.io/v1beta1 kind: MachineSet metadata: labels: machine.openshift.io/cluster-api-cluster: <infrastructureID> 1 machine.openshift.io/cluster-api-machine-role: infra 2 machine.openshift.io/cluster-api-machine-type: infra 3 name: <infrastructureID>-infra-<region> 4 namespace: openshift-machine-api spec: replicas: 1 selector: matchLabels: machine.openshift.io/cluster-api-cluster: <infrastructureID> 5 machine.openshift.io/cluster-api-machineset: <infrastructureID>-infra-<region> 6 template: metadata: creationTimestamp: null labels: machine.openshift.io/cluster-api-cluster: <infrastructureID> 7 machine.openshift.io/cluster-api-machine-role: infra 8 machine.openshift.io/cluster-api-machine-type: infra 9 machine.openshift.io/cluster-api-machineset: <infrastructureID>-infra-<region> 10 spec: metadata: creationTimestamp: null labels: node-role.kubernetes.io/infra: "" 11 taints: 12 - key: node-role.kubernetes.io/infra effect: NoSchedule providerSpec: value: apiVersion: azureproviderconfig.openshift.io/v1beta1 credentialsSecret: name: azure-cloud-credentials namespace: openshift-machine-api image: offer: "" publisher: "" resourceID: /resourceGroups/<infrastructureID>-rg/providers/Microsoft.Compute/images/<infrastructureID> sku: "" version: "" internalLoadBalancer: "" kind: AzureMachineProviderSpec location: centralus managedIdentity: <infrastructureID>-identity 13 metadata: creationTimestamp: null natRule: null networkResourceGroup: "" osDisk: diskSizeGB: 128 managedDisk: storageAccountType: Premium_LRS osType: Linux publicIP: false publicLoadBalancer: "" resourceGroup: <infrastructureID>-rg 14 sshPrivateKey: "" sshPublicKey: "" subnet: <infrastructureID>-<role>-subnet 15 16 userDataSecret: name: worker-user-data 17 vmSize: qeci-22538-vnet vnet: <infrastructureID>-vnet 18 zone: "1" 19
- 1 5 7 13 14 15 18
- クラスターのプロビジョニング時に設定したクラスター ID を基にするインフラストラクチャー ID を指定します。OpenShift CLI がインストールされている場合は、以下のコマンドを実行してインフラストラクチャー ID を取得できます。
$ oc get -o jsonpath='{.status.infrastructureName}{"\n"}' infrastructure cluster
以下のコマンドを実行してサブネットを取得できます。
$ oc -n openshift-machine-api \ -o jsonpath='{.spec.template.spec.providerSpec.value.subnet}{"\n"}' \ get machineset/<infrastructureID>-worker-centralus1
以下のコマンドを実行して vnet を取得できます。
$ oc -n openshift-machine-api \ -o jsonpath='{.spec.template.spec.providerSpec.value.vnet}{"\n"}' \ get machineset/<infrastructureID>-worker-centralus1
- 2 3 8 9 11 16 17
infra
ノードラベルを指定します。- 4 6 10
- インフラストラクチャー ID、
infra
ノードラベル、およびリージョンを指定します。 - 12
- ユーザーのワークロードが infra ノードにスケジュールされないようにテイントを指定します。
- 19
- マシンを配置するリージョン内のゾーンを指定します。リージョンがゾーンをサポートすることを確認してください。
6.2.1.3. GCP 上のマシンセットのカスタムリソースのサンプル YAML
このサンプル YAML は、Google Cloud Platform (GCP) で実行され、node-role.kubernetes.io/infra: ""
というラベルが付けられたノードを作成するマシンセットを定義します。
このサンプルでは、<infrastructureID>
はクラスターのプロビジョニング時に設定したクラスター ID に基づくインフラストラクチャー ID であり、infra
は追加するノードラベルです。
apiVersion: machine.openshift.io/v1beta1 kind: MachineSet metadata: labels: machine.openshift.io/cluster-api-cluster: <infrastructureID> 1 name: <infrastructureID>-w-a 2 namespace: openshift-machine-api spec: replicas: 1 selector: matchLabels: machine.openshift.io/cluster-api-cluster: <infrastructureID> 3 machine.openshift.io/cluster-api-machineset: <infrastructureID>-w-a 4 template: metadata: creationTimestamp: null labels: machine.openshift.io/cluster-api-cluster: <infrastructureID> 5 machine.openshift.io/cluster-api-machine-role: infra 6 machine.openshift.io/cluster-api-machine-type: infra 7 machine.openshift.io/cluster-api-machineset: <infrastructureID>-w-a 8 spec: metadata: labels: node-role.kubernetes.io/infra: "" 9 taints: 10 - key: node-role.kubernetes.io/infra effect: NoSchedule providerSpec: value: apiVersion: gcpprovider.openshift.io/v1beta1 canIPForward: false credentialsSecret: name: gcp-cloud-credentials deletionProtection: false disks: - autoDelete: true boot: true image: <path_to_image> 11 labels: null sizeGb: 128 type: pd-ssd kind: GCPMachineProviderSpec machineType: n1-standard-4 metadata: creationTimestamp: null networkInterfaces: - network: <infrastructureID>-network 12 subnetwork: <infrastructureID>-worker-subnet 13 projectID: <project_name> 14 region: us-central1 serviceAccounts: - email: <infrastructureID>-w@<project_name>.iam.gserviceaccount.com 15 16 scopes: - https://www.googleapis.com/auth/cloud-platform tags: - <infrastructureID>-worker 17 userDataSecret: name: worker-user-data zone: us-central1-a
- 1 2 3 4 5 8 12 13 15 17
- クラスターのプロビジョニング時に設定したクラスター ID を基にするインフラストラクチャー ID を指定します。OpenShift CLI がインストールされている場合は、以下のコマンドを実行してインフラストラクチャー ID を取得できます。
$ oc get -o jsonpath='{.status.infrastructureName}{"\n"}' infrastructure cluster
- 6 7 9
infra
ノードラベルを指定します。- 10
- ユーザーのワークロードが infra ノードにスケジュールされないようにテイントを指定します。
- 11
- 現在のマシンセットで使用されるイメージへのパスを指定します。OpenShift CLI がインストールされている場合は、以下のコマンドを実行してイメージへのパスを取得できます。
$ oc -n openshift-machine-api \ -o jsonpath='{.spec.template.spec.providerSpec.value.disks[0].image}{"\n"}' \ get machineset/<infrastructureID>-worker-a
- 14 16
- クラスターに使用する GCP プロジェクトの名前を指定します。
6.2.1.4. RHOSP 上のマシンセットのカスタムリソースのサンプル YAML
このサンプル YAML は、Red Hat OpenStack Platform (RHOSP) で実行され、node-role.kubernetes.io/infra: ""
というラベルが付けられたノードを作成するマシンセットを定義します。
このサンプルでは、infrastructure_ID
はクラスターのプロビジョニング時に設定したクラスター ID に基づくインフラストラクチャー ID であり、infra
は追加するノードラベルです。
apiVersion: machine.openshift.io/v1beta1 kind: MachineSet metadata: labels: machine.openshift.io/cluster-api-cluster: <infrastructure_ID> 1 machine.openshift.io/cluster-api-machine-role: infra 2 machine.openshift.io/cluster-api-machine-type: infra 3 name: <infrastructure_ID>-infra 4 namespace: openshift-machine-api spec: replicas: <number_of_replicas> selector: matchLabels: machine.openshift.io/cluster-api-cluster: <infrastructure_ID> 5 machine.openshift.io/cluster-api-machineset: <infrastructure_ID>-infra 6 template: metadata: labels: machine.openshift.io/cluster-api-cluster: <infrastructure_ID> 7 machine.openshift.io/cluster-api-machine-role: infra 8 machine.openshift.io/cluster-api-machine-type: infra 9 machine.openshift.io/cluster-api-machineset: <infrastructure_ID>-infra 10 spec: metadata: creationTimestamp: null labels: node-role.kubernetes.io/infra: "" taints: 11 - key: node-role.kubernetes.io/infra effect: NoSchedule providerSpec: value: apiVersion: openstackproviderconfig.openshift.io/v1alpha1 cloudName: openstack cloudsSecret: name: openstack-cloud-credentials namespace: openshift-machine-api flavor: <nova_flavor> image: <glance_image_name_or_location> serverGroupID: <optional_UUID_of_server_group> 12 kind: OpenstackProviderSpec networks: 13 - filter: {} subnets: - filter: name: <subnet_name> tags: openshiftClusterID=<infrastructure_ID> primarySubnet: <rhosp_subnet_UUID> 14 securityGroups: - filter: {} name: <infrastructure_ID>-worker serverMetadata: Name: <infrastructure_ID>-worker openshiftClusterID: <infrastructure_ID> tags: - openshiftClusterID=<infrastructure_ID> trunk: true userDataSecret: name: worker-user-data 15 availabilityZone: <optional_openstack_availability_zone>
- 1 5 7
- クラスターのプロビジョニング時に設定したクラスター ID を基にするインフラストラクチャー ID を指定します。OpenShift CLI がインストールされている場合は、以下のコマンドを実行してインフラストラクチャー ID を取得できます。
$ oc get -o jsonpath='{.status.infrastructureName}{"\n"}' infrastructure cluster
- 2 3 8 9 15
infra
ノードラベルを指定します。- 4 6 10
- インフラストラクチャー ID および
infra
ノードラベルを指定します。 - 11
- ユーザーのワークロードが infra ノードにスケジュールされないようにテイントを指定します。
- 12
- MachineSet のサーバーグループポリシーを設定するには、サーバーグループの作成 から返された値を入力します。ほとんどのデプロイメントでは、
anti-affinity
またはsoft-anti-affinity
が推奨されます。 - 13
- 複数ネットワークへのデプロイメントに必要です。複数ネットワークにデプロイする場合、この一覧には、
primarySubnet が
の値として使用されるネットワークが含まれる必要があります。 - 14
- ノードのエンドポイントを公開する RHOSP サブネットを指定します。通常、これは
install-config.yaml
ファイルのmachinesSubnet
の値として使用される同じサブネットです。
6.2.1.5. RHV 上のマシンセットのカスタムリソースのサンプル YAML
このサンプル YAML は、RHV で実行され、node-role.kubernetes.io/<node_role>: ""
というラベルが付けられたノードを作成するマシンセットを定義します。
このサンプルでは、<infrastructure_id>
はクラスターのプロビジョニング時に設定したクラスター ID に基づくインフラストラクチャー ID であり、<role>
は追加するノードラベルです。
apiVersion: machine.openshift.io/v1beta1 kind: MachineSet metadata: labels: machine.openshift.io/cluster-api-cluster: <infrastructure_id> 1 machine.openshift.io/cluster-api-machine-role: <role> 2 machine.openshift.io/cluster-api-machine-type: <role> 3 name: <infrastructure_id>-<role> 4 namespace: openshift-machine-api spec: replicas: <number_of_replicas> 5 Selector: 6 matchLabels: machine.openshift.io/cluster-api-cluster: <infrastructure_id> 7 machine.openshift.io/cluster-api-machineset: <infrastructure_id>-<role> 8 template: metadata: labels: machine.openshift.io/cluster-api-cluster: <infrastructure_id> 9 machine.openshift.io/cluster-api-machine-role: <role> 10 machine.openshift.io/cluster-api-machine-type: <role> 11 machine.openshift.io/cluster-api-machineset: <infrastructure_id>-<role> 12 spec: metadata: labels: node-role.kubernetes.io/<role>: "" 13 providerSpec: value: apiVersion: ovirtproviderconfig.machine.openshift.io/v1beta1 cluster_id: <ovirt_cluster_id> 14 template_name: <ovirt_template_name> 15 instance_type_id: <instance_type_id> 16 cpu: 17 sockets: <number_of_sockets> 18 cores: <number_of_cores> 19 threads: <number_of_threads> 20 memory_mb: <memory_size> 21 os_disk: 22 size_gb: <disk_size> 23 network_interfaces: 24 vnic_profile_id: <vnic_profile_id> 25 credentialsSecret: name: ovirt-credentials 26 kind: OvirtMachineProviderSpec type: <workload_type> 27 userDataSecret: name: worker-user-data
- 1 7 9
- クラスターのプロビジョニング時に設定したクラスター ID を基にするインフラストラクチャー ID を指定します。OpenShift CLI (
oc
) がインストールされている場合は、以下のコマンドを実行してインフラストラクチャー ID を取得できます。$ oc get -o jsonpath='{.status.infrastructureName}{"\n"}' infrastructure cluster
- 2 3 10 11 13
- 追加するノードラベルを指定します。
- 4 8 12
- インフラストラクチャー ID およびノードラベルを指定します。これら 2 つの文字列は 35 文字を超えることができません。
- 5
- 作成するマシンの数を指定します。
- 6
- マシンのセレクター。
- 14
- この仮想マシンインスタンスが属する RHV クラスターの UUID を指定します。
- 15
- マシンの作成に使用する RHV 仮想マシンテンプレートを指定します。
- 16
- オプション: 仮想マシンインスタンスタイプを指定します。このパラメーターを含めると、CPU およびメモリーを含む仮想マシンのハードウェアパラメーターを指定する必要はありません。このパラメーターは、すべてのハードウェアパラメーターを上書きするためです。
- 17
- オプション: CPU フィールドには、ソケット、コア、スレッドを含む CPU の設定が含まれます。
- 18
- オプション: 仮想マシンのソケット数を指定します。
- 19
- オプション: ソケットあたりのコア数を指定します。
- 20
- オプション: コアあたりのスレッド数を指定します。
- 21
- オプション: 仮想マシンのメモリーサイズを MiB 単位で指定します。
- 22
- オプション: ノードのルートディスク。
- 23
- オプション: ブート可能なディスクのサイズを GiB 単位で指定します。
- 24
- オプション: 仮想マシンのネットワークインターフェイスの一覧。このパラメーターを含めると、OpenShift Container Platform はテンプレートからすべてのネットワークインターフェイスを破棄し、新規ネットワークインターフェイスを作成します。
- 25
- オプション: vNIC プロファイル ID を指定します。
- 26
- RHV 認証情報を保持するシークレットの名前を指定します。
- 27
- オプション: インスタンスが最適化されるワークロードタイプを指定します。この値は
RHV VM
パラメーターに影響します。サポートされる値:desktop
、server
、high_performance
です。
RHV は仮想マシンの作成時にテンプレートを使用するため、任意のパラメーターの値を指定しない場合、RHV はテンプレートに指定されるパラメーターの値を使用します。
6.2.1.6. vSphere 上のマシンセットのカスタムリソースのサンプル YAML
このサンプル YAML は、VMware vSphere で実行され、 node-role.kubernetes.io/infra: ""
というラベルが付けられたノードを作成するマシンセットを定義します。
このサンプルでは、infrastructure_id
はクラスターのプロビジョニング時に設定したクラスター ID に基づくインフラストラクチャー ID であり、infra
は追加するノードラベルです。
apiVersion: machine.openshift.io/v1beta1 kind: MachineSet metadata: creationTimestamp: null labels: machine.openshift.io/cluster-api-cluster: <infrastructure_id> 1 name: <infrastructure_id>-infra 2 namespace: openshift-machine-api spec: replicas: 1 selector: matchLabels: machine.openshift.io/cluster-api-cluster: <infrastructure_id> 3 machine.openshift.io/cluster-api-machineset: <infrastructure_id>-infra 4 template: metadata: creationTimestamp: null labels: machine.openshift.io/cluster-api-cluster: <infrastructure_id> 5 machine.openshift.io/cluster-api-machine-role: infra 6 machine.openshift.io/cluster-api-machine-type: infra 7 machine.openshift.io/cluster-api-machineset: <infrastructure_id>-infra 8 spec: metadata: creationTimestamp: null labels: node-role.kubernetes.io/infra: "" 9 taints: 10 - key: node-role.kubernetes.io/infra effect: NoSchedule providerSpec: value: apiVersion: vsphereprovider.openshift.io/v1beta1 credentialsSecret: name: vsphere-cloud-credentials diskGiB: 120 kind: VSphereMachineProviderSpec memoryMiB: 8192 metadata: creationTimestamp: null network: devices: - networkName: "<vm_network_name>" 11 numCPUs: 4 numCoresPerSocket: 1 snapshot: "" template: <vm_template_name> 12 userDataSecret: name: worker-user-data workspace: datacenter: <vcenter_datacenter_name> 13 datastore: <vcenter_datastore_name> 14 folder: <vcenter_vm_folder_path> 15 resourcepool: <vsphere_resource_pool> 16 server: <vcenter_server_ip> 17
- 1 3 5
- クラスターのプロビジョニング時に設定したクラスター ID を基にするインフラストラクチャー ID を指定します。OpenShift CLI (
oc
) がインストールされている場合は、以下のコマンドを実行してインフラストラクチャー ID を取得できます。$ oc get -o jsonpath='{.status.infrastructureName}{"\n"}' infrastructure cluster
- 2 4 8
- インフラストラクチャー ID および
infra
ノードラベルを指定します。 - 6 7 9
infra
ノードラベルを指定します。- 10
- ユーザーのワークロードが infra ノードにスケジュールされないようにテイントを指定します。
- 11
- マシンセットをデプロイする vSphere 仮想マシンネットワークを指定します。
- 12
user-5ddjd-rhcos
などの使用する vSphere 仮想マシンテンプレートを指定します。- 13
- マシンセットをデプロイする vCenter Datacenter を指定します。
- 14
- マシンセットをデプロイする vCenter Datastore を指定します。
- 15
/dc1/vm/user-inst-5ddjd
などの vCenter の vSphere 仮想マシンフォルダーへのパスを指定します。- 16
- 仮想マシンの vSphere リソースプールを指定します。
- 17
- vCenter サーバーの IP または完全修飾ドメイン名を指定します。