13.15. AWS でのブートストラップノードの作成
OpenShift Container Platform クラスターの初期化で使用するブートストラップノードを Amazon Web Services (AWS) で作成する必要があります。これは、以下の方法で行います。
-
bootstrap.ignIgnition 設定ファイルをクラスターに送るための場所を指定。このファイルはインストールディレクトリーに置かれます。提供される CloudFormation テンプレートでは、クラスターの Ignition 設定ファイルは S3 バケットから送られることを前提としています。このファイルを別の場所から送ることを選択する場合は、テンプレートを変更する必要があります。 - 提供される CloudFormation テンプレートおよびカスタムパラメーターファイルを使用して、AWS リソースのスタックを作成できます。スタックは、OpenShift Container Platform インストールに必要なブートストラップノードを表します。
提供される CloudFormation テンプレートを使用してブートストラップノードを作成しない場合、提供される情報を確認し、インフラストラクチャーを手動で作成する必要があります。クラスターが適切に初期化されない場合、インストールログを用意して Red Hat サポートに問い合わせする必要がある可能性があります。
前提条件
- AWS アカウントを設定している。
-
aws configureを実行して、AWS キーおよびリージョンをローカルの AWS プロファイルに追加している。 - クラスターの Ignition 設定ファイルを生成している。
- AWS で VPC および関連するサブネットを作成し、設定している。
- AWS で DNS、ロードバランサー、およびリスナーを作成し、設定している。
- AWS でクラスターに必要なセキュリティーグループおよびロールを作成している。
手順
以下のコマンドを実行してバケットを作成します。
$ aws s3 mb s3://<cluster-name>-infra1 - 1
<cluster-name>-infraはバケット名です。install-config.yamlファイルを作成する際に、<cluster-name>をクラスターに指定された名前に置き換えます。
以下の場合は、
s3://スキーマではなく、S3 バケットに事前に署名された URL を使用する必要があります。- AWS SDK とは異なるエンドポイントを持つリージョンへのデプロイ。
- プロキシーをデプロイする。
- カスタムエンドポイントを指定します。
以下のコマンドを実行して
bootstrap.ignIgnition 設定ファイルをバケットにアップロードします。$ aws s3 cp <installation_directory>/bootstrap.ign s3://<cluster-name>-infra/bootstrap.ign1 - 1
<installation_directory>には、インストールファイルを保存したディレクトリーへのパスを指定します。
以下のコマンドを実行して、ファイルがアップロードされていることを確認します。
$ aws s3 ls s3://<cluster-name>-infra/出力例
2019-04-03 16:15:16 314878 bootstrap.ign注記ブートストラップ Ignition 設定ファイルには、X.509 キーのようなシークレットが含まれません。以下の手順では、S3 バケットの基本的なセキュリティーを提供します。追加のセキュリティーを提供するには、OpenShift IAM ユーザーなどの特定のユーザーのみがバケットに含まれるオブジェクトにアクセスできるように S3 バケットポリシーを有効にできます。S3 を完全に回避し、ブートストラップマシンが到達できるアドレスからブートストラップ Ignition 設定ファイルを送ることができます。
テンプレートが必要とするパラメーター値が含まれる JSON ファイルを作成します。
[ { "ParameterKey": "InfrastructureName",1 "ParameterValue": "mycluster-<random_string>"2 }, { "ParameterKey": "RhcosAmi",3 "ParameterValue": "ami-<random_string>"4 }, { "ParameterKey": "AllowedBootstrapSshCidr",5 "ParameterValue": "0.0.0.0/0"6 }, { "ParameterKey": "PublicSubnet",7 "ParameterValue": "subnet-<random_string>"8 }, { "ParameterKey": "MasterSecurityGroupId",9 "ParameterValue": "sg-<random_string>"10 }, { "ParameterKey": "VpcId",11 "ParameterValue": "vpc-<random_string>"12 }, { "ParameterKey": "BootstrapIgnitionLocation",13 "ParameterValue": "s3://<bucket_name>/bootstrap.ign"14 }, { "ParameterKey": "AutoRegisterELB",15 "ParameterValue": "yes"16 }, { "ParameterKey": "RegisterNlbIpTargetsLambdaArn",17 "ParameterValue": "arn:aws:lambda:<aws_region>:<account_number>:function:<dns_stack_name>-RegisterNlbIpTargets-<random_string>"18 }, { "ParameterKey": "ExternalApiTargetGroupArn",19 "ParameterValue": "arn:aws:elasticloadbalancing:<aws_region>:<account_number>:targetgroup/<dns_stack_name>-Exter-<random_string>"20 }, { "ParameterKey": "InternalApiTargetGroupArn",21 "ParameterValue": "arn:aws:elasticloadbalancing:<aws_region>:<account_number>:targetgroup/<dns_stack_name>-Inter-<random_string>"22 }, { "ParameterKey": "InternalServiceTargetGroupArn",23 "ParameterValue": "arn:aws:elasticloadbalancing:<aws_region>:<account_number>:targetgroup/<dns_stack_name>-Inter-<random_string>"24 } ]- 1
- クラスターの Ignition 設定ファイルでエンコードされるクラスターインフラストラクチャーの名前。
- 2
- 形式が
<cluster-name>-<random-string>の Ignition 設定ファイルから抽出したインフラストラクチャー名を指定します。 - 3
- 選択したアーキテクチャーに基づいてブートストラップノードに使用する最新の Red Hat Enterprise Linux CoreOS (RHCOS) AMI。
- 4
- 有効な
AWS::EC2::Image::Id値を指定します。 - 5
- ブートストラップノードへの SSH アクセスを許可する CIDR ブロック。
- 6
x.x.x.x/16-24形式で CIDR ブロックを指定します。- 7
- ブートストラップを起動するために VPC に関連付けられるパブリックサブネット。
- 8
- VPC の CloudFormation テンプレートの出力から
PublicSubnetIds値を指定します。 - 9
- マスターセキュリティーグループ ID (一時ルールの登録用)。
- 10
- セキュリティーグループおよびロールの CloudFormation テンプレートから
MasterSecurityGroupId値を指定します。 - 11
- 作成されたリソースが属する VPC。
- 12
- VPC の CloudFormation テンプレートの出力から
VpcId値を指定します。 - 13
- ブートストラップの Ignition 設定ファイルをフェッチする場所。
- 14
s3://<bucket_name>/bootstrap.ignの形式で S3 バケットおよびファイル名を指定します。- 15
- ネットワークロードバランサー (NLB) を登録するかどうか。
- 16
yesまたはnoを指定します。yesを指定する場合、Lambda Amazon Resource Name (ARN) の値を指定する必要があります。- 17
- NLB IP ターゲット登録 lambda グループの ARN。
- 18
- DNS および負荷分散の CloudFormation テンプレートの出力から
RegisterNlbIpTargetsLambda値を指定します。クラスターを AWS GovCloud リージョンにデプロイする場合は、arn:aws-us-govを使用します。 - 19
- 外部 API ロードバランサーのターゲットグループの ARN。
- 20
- DNS および負荷分散の CloudFormation テンプレートの出力から
ExternalApiTargetGroupArn値を指定します。クラスターを AWS GovCloud リージョンにデプロイする場合は、arn:aws-us-govを使用します。 - 21
- 内部 API ロードバランサーのターゲットグループの ARN。
- 22
- DNS および負荷分散の CloudFormation テンプレートの出力から
InternalApiTargetGroupArn値を指定します。クラスターを AWS GovCloud リージョンにデプロイする場合は、arn:aws-us-govを使用します。 - 23
- 内部サービスバランサーのターゲットグループの ARN。
- 24
- DNS および負荷分散の CloudFormation テンプレートの出力から
InternalServiceTargetGroupArn値を指定します。クラスターを AWS GovCloud リージョンにデプロイする場合は、arn:aws-us-govを使用します。
- このトピックの ブートストラップマシンの CloudFormation テンプレート セクションからテンプレートをコピーし、これをコンピューター上に YAML ファイルとして保存します。このテンプレートは、クラスターに必要なブートストラップマシンを記述しています。
-
オプション: プロキシーを使用してクラスターをデプロイする場合は、テンプレートの ignition を更新して
ignition.config.proxyフィールドを追加する必要があります。さらに、Amazon EC2、Elastic Load Balancing、および S3 VPC エンドポイントを VPC に追加している場合は、これらのエンドポイントをnoProxyフィールドに追加する必要があります。 CloudFormation テンプレートを起動し、ブートストラップノードを表す AWS リソースのスタックを作成します。
重要単一行にコマンドを入力してください。
$ aws cloudformation create-stack --stack-name <name>1 --template-body file://<template>.yaml2 --parameters file://<parameters>.json3 --capabilities CAPABILITY_NAMED_IAM4 - 1
<name>はcluster-bootstrapなどの CloudFormation スタックの名前です。クラスターを削除する場合に、このスタックの名前が必要になります。- 2
<template>は、保存した CloudFormation テンプレート YAML ファイルへの相対パスまたはその名前です。- 3
<parameters>は、CloudFormation パラメーター JSON ファイルへの相対パスまたは名前です。- 4
- 提供されるテンプレートは一部の
AWS::IAM::RoleおよびAWS::IAM::InstanceProfileリソースを作成するため、CAPABILITY_NAMED_IAM機能を明示的に宣言する必要があります。
出力例
arn:aws:cloudformation:us-east-1:269333783861:stack/cluster-bootstrap/12944486-2add-11eb-9dee-12dace8e3a83テンプレートのコンポーネントが存在することを確認します。
$ aws cloudformation describe-stacks --stack-name <name>StackStatusがCREATE_COMPLETEを表示した後に、出力には以下のパラメーターの値が表示されます。これらのパラメーターの値をクラスターを作成するために実行する他の CloudFormation テンプレートに指定する必要があります。BootstrapInstanceIdブートストラップインスタンス ID。
BootstrapPublicIpブートストラップノードのパブリック IP アドレス。
BootstrapPrivateIpブートストラップノードのプライベート IP アドレス。
13.15.1. ブートストラップマシンの CloudFormation テンプレート リンクのコピーリンクがクリップボードにコピーされました!
以下の CloudFormation テンプレートを使用し、OpenShift Container Platform クラスターに必要なブートストラップマシンをデプロイできます。
例13.19 ブートストラップマシンの CloudFormation テンプレート
AWSTemplateFormatVersion: 2010-09-09
Description: Template for OpenShift Cluster Bootstrap (EC2 Instance, Security Groups and IAM)
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 cloud resources and identify items owned or used by the cluster.
Type: String
RhcosAmi:
Description: Current Red Hat Enterprise Linux CoreOS AMI to use for bootstrap.
Type: AWS::EC2::Image::Id
AllowedBootstrapSshCidr:
AllowedPattern: ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|1[0-9]|2[0-9]|3[0-2]))$
ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/0-32.
Default: 0.0.0.0/0
Description: CIDR block to allow SSH access to the bootstrap node.
Type: String
PublicSubnet:
Description: The public subnet to launch the bootstrap node into.
Type: AWS::EC2::Subnet::Id
MasterSecurityGroupId:
Description: The master security group ID for registering temporary rules.
Type: AWS::EC2::SecurityGroup::Id
VpcId:
Description: The VPC-scoped resources will belong to this VPC.
Type: AWS::EC2::VPC::Id
BootstrapIgnitionLocation:
Default: s3://my-s3-bucket/bootstrap.ign
Description: Ignition config file location.
Type: String
AutoRegisterELB:
Default: "yes"
AllowedValues:
- "yes"
- "no"
Description: Do you want to invoke NLB registration, which requires a Lambda ARN parameter?
Type: String
RegisterNlbIpTargetsLambdaArn:
Description: ARN for NLB IP target registration lambda.
Type: String
ExternalApiTargetGroupArn:
Description: ARN for external API load balancer target group.
Type: String
InternalApiTargetGroupArn:
Description: ARN for internal API load balancer target group.
Type: String
InternalServiceTargetGroupArn:
Description: ARN for internal service load balancer target group.
Type: String
BootstrapInstanceType:
Description: Instance type for the bootstrap EC2 instance
Default: "i3.large"
Type: String
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: "Cluster Information"
Parameters:
- InfrastructureName
- Label:
default: "Host Information"
Parameters:
- RhcosAmi
- BootstrapIgnitionLocation
- MasterSecurityGroupId
- Label:
default: "Network Configuration"
Parameters:
- VpcId
- AllowedBootstrapSshCidr
- PublicSubnet
- Label:
default: "Load Balancer Automation"
Parameters:
- AutoRegisterELB
- RegisterNlbIpTargetsLambdaArn
- ExternalApiTargetGroupArn
- InternalApiTargetGroupArn
- InternalServiceTargetGroupArn
ParameterLabels:
InfrastructureName:
default: "Infrastructure Name"
VpcId:
default: "VPC ID"
AllowedBootstrapSshCidr:
default: "Allowed SSH Source"
PublicSubnet:
default: "Public Subnet"
RhcosAmi:
default: "Red Hat Enterprise Linux CoreOS AMI ID"
BootstrapIgnitionLocation:
default: "Bootstrap Ignition Source"
MasterSecurityGroupId:
default: "Master Security Group ID"
AutoRegisterELB:
default: "Use Provided ELB Automation"
Conditions:
DoRegistration: !Equals ["yes", !Ref AutoRegisterELB]
Resources:
BootstrapIamRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Principal:
Service:
- "ec2.amazonaws.com"
Action:
- "sts:AssumeRole"
Path: "/"
Policies:
- PolicyName: !Join ["-", [!Ref InfrastructureName, "bootstrap", "policy"]]
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Action: "ec2:Describe*"
Resource: "*"
- Effect: "Allow"
Action: "ec2:AttachVolume"
Resource: "*"
- Effect: "Allow"
Action: "ec2:DetachVolume"
Resource: "*"
- Effect: "Allow"
Action: "s3:GetObject"
Resource: "*"
BootstrapInstanceProfile:
Type: "AWS::IAM::InstanceProfile"
Properties:
Path: "/"
Roles:
- Ref: "BootstrapIamRole"
BootstrapSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Cluster Bootstrap Security Group
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 22
ToPort: 22
CidrIp: !Ref AllowedBootstrapSshCidr
- IpProtocol: tcp
ToPort: 19531
FromPort: 19531
CidrIp: 0.0.0.0/0
VpcId: !Ref VpcId
BootstrapInstance:
Type: AWS::EC2::Instance
Properties:
ImageId: !Ref RhcosAmi
IamInstanceProfile: !Ref BootstrapInstanceProfile
InstanceType: !Ref BootstrapInstanceType
NetworkInterfaces:
- AssociatePublicIpAddress: "true"
DeviceIndex: "0"
GroupSet:
- !Ref "BootstrapSecurityGroup"
- !Ref "MasterSecurityGroupId"
SubnetId: !Ref "PublicSubnet"
UserData:
Fn::Base64: !Sub
- '{"ignition":{"config":{"replace":{"source":"${S3Loc}"}},"version":"3.1.0"}}'
- {
S3Loc: !Ref BootstrapIgnitionLocation
}
RegisterBootstrapApiTarget:
Condition: DoRegistration
Type: Custom::NLBRegister
Properties:
ServiceToken: !Ref RegisterNlbIpTargetsLambdaArn
TargetArn: !Ref ExternalApiTargetGroupArn
TargetIp: !GetAtt BootstrapInstance.PrivateIp
RegisterBootstrapInternalApiTarget:
Condition: DoRegistration
Type: Custom::NLBRegister
Properties:
ServiceToken: !Ref RegisterNlbIpTargetsLambdaArn
TargetArn: !Ref InternalApiTargetGroupArn
TargetIp: !GetAtt BootstrapInstance.PrivateIp
RegisterBootstrapInternalServiceTarget:
Condition: DoRegistration
Type: Custom::NLBRegister
Properties:
ServiceToken: !Ref RegisterNlbIpTargetsLambdaArn
TargetArn: !Ref InternalServiceTargetGroupArn
TargetIp: !GetAtt BootstrapInstance.PrivateIp
Outputs:
BootstrapInstanceId:
Description: Bootstrap Instance ID.
Value: !Ref BootstrapInstance
BootstrapPublicIp:
Description: The bootstrap node public IP address.
Value: !GetAtt BootstrapInstance.PublicIp
BootstrapPrivateIp:
Description: The bootstrap node private IP address.
Value: !GetAtt BootstrapInstance.PrivateIp