4.12.12. AWS에서 부트스트랩 노드 생성

OpenShift Container Platform 클러스터 초기화 과정에서 사용할 부트스트랩 노드를 AWS(Amazon Web Services)에서 생성해야 합니다.

제공된 CloudFormation 템플릿과 사용자 정의 매개변수 파일을 사용하여 AWS 리소스 스택을 생성할 수 있습니다. 스택은 OpenShift Container Platform 설치에 필요한 부트스트랩 노드를 나타냅니다.

참고

부트스트랩 노드를 생성하는 데 제공된 CloudFormation 템플릿을 사용하지 않는 경우, 제공된 정보를 검토하고 수동으로 인프라를 생성해야 합니다.. 클러스터가 올바르게 초기화되지 않은 경우, Red Hat 지원팀에 설치 로그를 제시하여 문의해야 할 수도 있습니다.

사전 요구 사항

  • AWS 계정을 구성했습니다.
  • aws 구성을 실행하여 AWS 키와 리전을 로컬 AWS 프로필에 추가하셨습니다.
  • 클러스터에 대한 Ignition 구성 파일을 생성하셨습니다.
  • AWS에서 VPC 및 관련 서브넷을 생성하고 구성하셨습니다.
  • AWS에서 DNS, 로드 밸런서 및 리스너를 생성하고 구성하셨습니다.
  • AWS에서 클러스터에 필요한 보안 그룹 및 역할을 생성하셨습니다.

프로세스

  1. bootstrap.ign Ignition 구성 파일을 클러스터에 제공할 위치를 지정합니다. 이 파일은 설치 디렉터리에 있습니다. 한 가지 방법은 클러스터의 리전에 S3 버킷을 생성하고 여기에 Ignition 구성 파일을 업로드하는 것입니다.

    중요

    제공된 CloudFormation 템플릿은 클러스터의 Ignition 구성 파일이 S3 버킷에서 제공되는 것으로 가정합니다. 다른 위치에서 파일을 제공하려면 템플릿을 수정해야 합니다.

    중요

    AWS SDK와 다른 엔드 포인트가 있는 리전에 배포하거나 자체 사용자 지정 엔드 포인트를 제공하는 경우 s3:// 스키마 대신 사전에 서명된 URL을 S3 버킷에 사용해야 합니다.

    참고

    부트스트랩 Ignition 구성 파일에는 X.509 키와 같은 시크릿이 포함되어 있습니다. 다음 단계는 S3 버킷에 대한 기본 보안을 제공합니다. 추가 보안을 제공하기 위해 OpenShift IAM 사용자와 같은 특정 사용자만 버킷에 포함된 개체에 액세스할 수 있도록 S3 버킷 정책을 활성화할 수 있습니다. S3과 관계없이 부트스트랩 시스템이 도달할 수 있는 모든 주소에서 부트스트랩 Ignition 구성 파일을 제공할 수 있습니다.

    1. 버킷을 만듭니다.

      $ aws s3 mb s3://<cluster-name>-infra 1
      1
      <cluster-name>-infra는 버킷 이름입니다. install-config.yaml 파일을 생성할 때 <cluster-name>을 클러스터에 지정된 이름으로 교체합니다.
    2. bootstrap.ign Ignition 구성 파일을 버킷에 업로드합니다.

      $ aws s3 cp <installation_directory>/bootstrap.ign s3://<cluster-name>-infra/bootstrap.ign 1
      1
      <installation_directory>는 설치 파일을 저장한 디렉터리의 경로를 지정합니다.
    3. 파일이 업로드되었는지 확인합니다.

      $ aws s3 ls s3://<cluster-name>-infra/

      출력 예

      2019-04-03 16:15:16     314878 bootstrap.ign

  2. 템플릿에 필요한 매개변수 값이 포함된 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:<region>:<account_number>:function:<dns_stack_name>-RegisterNlbIpTargets-<random_string>" 18
      },
      {
        "ParameterKey": "ExternalApiTargetGroupArn", 19
        "ParameterValue": "arn:aws:elasticloadbalancing:<region>:<account_number>:targetgroup/<dns_stack_name>-Exter-<random_string>" 20
      },
      {
        "ParameterKey": "InternalApiTargetGroupArn", 21
        "ParameterValue": "arn:aws:elasticloadbalancing:<region>:<account_number>:targetgroup/<dns_stack_name>-Inter-<random_string>" 22
      },
      {
        "ParameterKey": "InternalServiceTargetGroupArn", 23
        "ParameterValue": "arn:aws:elasticloadbalancing:<region>:<account_number>:targetgroup/<dns_stack_name>-Inter-<random_string>" 24
      }
    ]
    1
    클러스터에 대해 Ignition 구성 파일에 인코딩되는 클러스터 인프라의 이름입니다.
    2
    Ignition 구성 파일 메타데이터에서 추출한 인프라 이름을 <cluster-name>-<random-string> 형식으로 지정합니다.
    3
    부트스트랩 노드에 사용할 현재 RHCOS(Red Hat Enterprise Linux CoreOS) AMI입니다.
    4
    유효한 AWS::EC2::Image::Id 값을 지정합니다.
    5
    부트스트랩 노드에 대한 SSH 액세스를 허용하는 CIDR 블록입니다.
    6
    xxxx/16-24 형식으로 CIDR 블록을 지정합니다.
    7
    부트스트랩 노드를 시작하기 위해 VPC와 연결되는 퍼블릭 서브넷입니다.
    8
    VPC에 대한 CloudFormation 템플릿의 출력에서 PublicSubnetIds 값을 지정합니다.
    9
    마스터 보안 그룹 ID(임시 규칙 등록용)입니다.
    10
    보안 그룹 및 역할에 대한 CloudFormation 템플릿 출력에서 MasterSecurityGroupId 값을 지정합니다.
    11
    VPC 생성 리소스가 속합니다.
    12
    VPC에 대한 CloudFormation 템플릿의 출력에서 VpcId 값을 지정합니다.
    13
    부트스트랩 Ignition 구성 파일을 가져올 위치입니다.
    14
    S3 버킷과 파일 이름을 s3://<bucket_name>/bootstrap.ign 형식으로 지정합니다.
    15
    네트워크 로드 밸런서(NLB) 등록 여부입니다.
    16
    yes 또는 no를 지정합니다. yes를 지정하는 경우 Lambda ARN(Amazon Resource Name) 값을 제공해야 합니다.
    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를 사용합니다.
  3. 이 항목의 부트스트랩 시스템의 CloudFormation 템플릿 섹션에서 템플릿을 복사하여 사용자 시스템에 YAML 파일로 저장합니다. 이 템플릿은 클러스터에 필요한 부트스트랩 시스템을 설명합니다.
  4. CloudFormation 템플릿을 시작하여 부트스트랩 노드를 나타내는 AWS 리소스 스택을 생성합니다.

    중요

    명령은 한 줄로 입력해야 합니다.

    $ aws cloudformation create-stack --stack-name <name> 1
         --template-body file://<template>.yaml 2
         --parameters file://<parameters>.json 3
         --capabilities CAPABILITY_NAMED_IAM 4
    1
    <name>은 CloudFormation 스택의 이름입니다(예: cluster-bootstrap). 클러스터를 제거하는 경우 이 스택의 이름이 필요합니다.
    2
    <template>은 저장한 CloudFormation 템플릿 YAML 파일의 상대 경로 및 이름입니다.
    3
    <parameters>는 CloudFormation 매개변수 JSON 파일의 상대 경로 및 이름입니다.
    4
    제공된 템플릿에서 일부 AWS::IAM::RoleAWS::IAM::InstanceProfile 리소스를 생성하므로 CAPABILITY_NAMED_IAM 기능을 명시적으로 선언해야 합니다.

    출력 예

    arn:aws:cloudformation:us-east-1:269333783861:stack/cluster-bootstrap/12944486-2add-11eb-9dee-12dace8e3a83

  5. 템플릿 구성 요소가 있는지 확인합니다.

    $ aws cloudformation describe-stacks --stack-name <name>

    StackStatusCREATE_COMPLETE이 표시된 후 다음 매개변수의 출력 값이 표시됩니다. 클러스터를 생성하기 위해 실행하는 다른 CloudFormation 템플릿에 이러한 매개변수 값을 제공해야 합니다.

    BootstrapInstanceId

    부트스트랩 인스턴스 ID입니다.

    BootstrapPublicIp

    부트스트랩 노드 공용 IP 주소입니다.

    BootstrapPrivateIp

    부트스트랩 노드 개인 IP 주소입니다.

4.12.12.1. 부트스트랩 시스템용 CloudFormation 템플릿

다음 CloudFormation 템플릿을 사용하여 OpenShift Container Platform 클러스터에 필요한 부트스트랩 시스템을 배포할 수 있습니다.

예 4.58. 부트스트랩 시스템용 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

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: "i3.large"
      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

추가 리소스

  • AWS 영역의 RHCOS(Red Hat Enterprise Linux CoreOS) AMI에 대한 자세한 내용은 AWS 인프라의 RHCOS AMI를 참조하십시오.