15.16. AWS でのワーカーノードの作成
クラスターで使用するワーカーノードを Amazon Web Services (AWS) で作成できます。
提供される CloudFormation テンプレートおよびカスタムパラメーターファイルを使用して、ワーカーノードを表す AWS リソースのスタックを作成できます。
CloudFormation テンプレートは、1 つのワーカーノードを表すスタックを作成します。それぞれのワーカーノードにスタックを作成する必要があります。
提供される CloudFormation テンプレートを使用してワーカーノードを作成しない場合、提供される情報を確認し、インフラストラクチャーを手動で作成する必要があります。クラスターが適切に初期化されない場合、インストールログを用意して Red Hat サポートに問い合わせする必要がある可能性があります。
前提条件
- AWS アカウントを設定している。
-
aws configure
を実行して、AWS キーおよびリージョンをローカルの AWS プロファイルに追加している。 - クラスターの Ignition 設定ファイルを生成している。
- AWS で VPC および関連するサブネットを作成し、設定している。
- AWS で DNS、ロードバランサー、およびリスナーを作成し、設定している。
- AWS でクラスターに必要なセキュリティーグループおよびロールを作成している。
- ブートストラップマシンを作成している。
- コントロールプレーンマシンを作成している。
手順
CloudFormation テンプレートが必要とするパラメーター値が含まれる JSON ファイルを作成します。
[ { "ParameterKey": "InfrastructureName", 1 "ParameterValue": "mycluster-<random_string>" 2 }, { "ParameterKey": "RhcosAmi", 3 "ParameterValue": "ami-<random_string>" 4 }, { "ParameterKey": "Subnet", 5 "ParameterValue": "subnet-<random_string>" 6 }, { "ParameterKey": "WorkerSecurityGroupId", 7 "ParameterValue": "sg-<random_string>" 8 }, { "ParameterKey": "IgnitionLocation", 9 "ParameterValue": "https://api-int.<cluster_name>.<domain_name>:22623/config/worker" 10 }, { "ParameterKey": "CertificateAuthorities", 11 "ParameterValue": "" 12 }, { "ParameterKey": "WorkerInstanceProfileName", 13 "ParameterValue": "" 14 }, { "ParameterKey": "WorkerInstanceType", 15 "ParameterValue": "" 16 } ]
- 1
- クラスターの Ignition 設定ファイルでエンコードされるクラスターインフラストラクチャーの名前。
- 2
- 形式が
<cluster-name>-<random-string>
の Ignition 設定ファイルから抽出したインフラストラクチャー名を指定します。 - 3
- 選択したアーキテクチャーに基づいてワーカーノードに使用する現在の Red Hat Enterprise Linux CoreOS (RHCOS) AMI。
- 4
AWS::EC2::Image::Id
値を指定します。- 5
- ワーカーノードを起動するためのサブネット (プライベートであることが望ましい)。
- 6
- DNS および負荷分散の CloudFormation テンプレートの出力から
PrivateSubnets
値のサブネットを指定します。 - 7
- ワーカーノードに関連付けるワーカーセキュリティーグループ ID。
- 8
- セキュリティーグループおよびロールの CloudFormation テンプレートの出力から
WorkerSecurityGroupId
値を指定します。 - 9
- ブートストラップ Ignition 設定ファイルを取得する場所。
- 10
- 生成される Ignition 設定の場所を指定します。
https://api-int.<cluster_name>.<domain_name>:22623/config/worker
- 11
- 使用する base64 でエンコードされた認証局の文字列。
- 12
- インストールディレクトリーにある
worker.ign
ファイルから値を指定します。この値は、data:text/plain;charset=utf-8;base64,ABC…xYz==
形式の長い文字列です。 - 13
- ワーカーロールに関連付ける IAM プロファイル。
- 14
- セキュリティーグループおよびロールの CloudFormation テンプレートの出力から
WorkerInstanceProfile
パラメーターの値を指定します。 - 15
- 選択したアーキテクチャーに基づいてコンピュートマシンに使用する AWS インスタンスのタイプ。
- 16
- インスタンスタイプの値は、コンピュートマシンの最小リソース要件に対応します。たとえば、
m6i.large
は AMD64 のタイプであり、m6g.large
は ARM64 のタイプです。
- このトピックのワーカーマシンの CloudFormation テンプレートセクションからテンプレートをコピーし、これをコンピューター上に YAML ファイルとして保存します。このテンプレートは、クラスターに必要なネットワークオブジェクトおよびロードバランサーを記述しています。
-
オプション:
m5
インスタンスタイプをWorkerInstanceType
の値として指定した場合は、そのインスタンスタイプを CloudFormation テンプレートのWorkerInstanceType.AllowedValues
パラメーターに追加します。 -
オプション: AWS Marketplace イメージを使用してデプロイする場合は、サブスクリプションから取得した AMI ID で
Worker0.type.properties.ImageID
パラメーターを更新します。 CloudFormation テンプレートを使用して、ワーカーノードを表す AWS リソースのスタックを作成します。
重要単一行にコマンドを入力してください。
$ aws cloudformation create-stack --stack-name <name> 1 --template-body file://<template>.yaml \ 2 --parameters file://<parameters>.json 3
出力例
arn:aws:cloudformation:us-east-1:269333783861:stack/cluster-worker-1/729ee301-1c2a-11eb-348f-sd9888c65b59
注記CloudFormation テンプレートは、1 つのワーカーノードを表すスタックを作成します。
テンプレートのコンポーネントが存在することを確認します。
$ aws cloudformation describe-stacks --stack-name <name>
クラスターに作成するワーカーマシンが十分な数に達するまでワーカースタックの作成を継続します。同じテンプレートおよびパラメーターファイルを参照し、異なるスタック名を指定してワーカースタックをさらに作成することができます。
重要2 つ以上のワーカーマシンを作成する必要があるため、この CloudFormation テンプレートを使用する 2 つ以上のスタックを作成する必要があります。
15.16.1. ワーカーマシンの CloudFormation テンプレート
以下の CloudFormation テンプレートを使用し、OpenShift Container Platform クラスターに必要なワーカーマシンをデプロイすることができます。
例15.21 ワーカーマシンの CloudFormation テンプレート
AWSTemplateFormatVersion: 2010-09-09 Description: Template for OpenShift Cluster Node Launch (EC2 worker instance) Parameters: InfrastructureName: AllowedPattern: ^([a-zA-Z][a-zA-Z0-9\-]{0,26})$ MaxLength: 27 MinLength: 1 ConstraintDescription: Infrastructure name must be alphanumeric, start with a letter, and have a maximum of 27 characters. Description: A short, unique cluster ID used to tag nodes for the kubelet cloud provider. Type: String RhcosAmi: Description: Current Red Hat Enterprise Linux CoreOS AMI to use for bootstrap. Type: AWS::EC2::Image::Id Subnet: Description: The subnets, recommend private, to launch the master nodes into. Type: AWS::EC2::Subnet::Id WorkerSecurityGroupId: Description: The master security group ID to associate with master nodes. Type: AWS::EC2::SecurityGroup::Id IgnitionLocation: Default: https://api-int.$CLUSTER_NAME.$DOMAIN:22623/config/worker Description: Ignition config file location. Type: String CertificateAuthorities: Default: data:text/plain;charset=utf-8;base64,ABC...xYz== Description: Base64 encoded certificate authority string to use. Type: String WorkerInstanceProfileName: Description: IAM profile to associate with master nodes. Type: String WorkerInstanceType: Default: m5.large Type: String Metadata: AWS::CloudFormation::Interface: ParameterGroups: - Label: default: "Cluster Information" Parameters: - InfrastructureName - Label: default: "Host Information" Parameters: - WorkerInstanceType - RhcosAmi - IgnitionLocation - CertificateAuthorities - WorkerSecurityGroupId - WorkerInstanceProfileName - Label: default: "Network Configuration" Parameters: - Subnet ParameterLabels: Subnet: default: "Subnet" InfrastructureName: default: "Infrastructure Name" WorkerInstanceType: default: "Worker Instance Type" WorkerInstanceProfileName: default: "Worker Instance Profile Name" RhcosAmi: default: "Red Hat Enterprise Linux CoreOS AMI ID" IgnitionLocation: default: "Worker Ignition Source" CertificateAuthorities: default: "Ignition CA String" WorkerSecurityGroupId: default: "Worker Security Group ID" Resources: Worker0: Type: AWS::EC2::Instance Properties: ImageId: !Ref RhcosAmi BlockDeviceMappings: - DeviceName: /dev/xvda Ebs: VolumeSize: "120" VolumeType: "gp2" IamInstanceProfile: !Ref WorkerInstanceProfileName InstanceType: !Ref WorkerInstanceType NetworkInterfaces: - AssociatePublicIpAddress: "false" DeviceIndex: "0" GroupSet: - !Ref "WorkerSecurityGroupId" SubnetId: !Ref "Subnet" UserData: Fn::Base64: !Sub - '{"ignition":{"config":{"merge":[{"source":"${SOURCE}"}]},"security":{"tls":{"certificateAuthorities":[{"source":"${CA_BUNDLE}"}]}},"version":"3.1.0"}}' - { SOURCE: !Ref IgnitionLocation, CA_BUNDLE: !Ref CertificateAuthorities, } Tags: - Key: !Join ["", ["kubernetes.io/cluster/", !Ref InfrastructureName]] Value: "shared" Outputs: PrivateIP: Description: The compute node private IP address. Value: !GetAtt Worker0.PrivateIp