Red Hat Training

A Red Hat training course is available for OpenShift Container Platform

43.3. 시작 구성 및 자동 확장 그룹 생성

클러스터 자동 확장기를 배포하기 전에 기본 이미지를 참조하는 AWS(Amazon Web Services) 시작 구성 및 자동 확장 그룹을 생성해야 합니다. 새 노드가 시작될 때 기존 클러스터에 자동으로 참여하도록 시작 구성을 구성해야 합니다.

사전 요구 사항

  • AWS에 OpenShift Container Platform 클러스터를 설치합니다.
  • 기본 이미지를 만듭니다.
  • 클러스터에 EFK 스택을 배포한 경우 노드 레이블을 logging-infra-fluentd=true 로 설정합니다.

절차

  1. 마스터 노드에서 부트스트랩.kubeconfig 파일을 생성합니다.

    $ ssh master "sudo oc serviceaccounts create-kubeconfig -n openshift-infra node-bootstrapper" > ~/bootstrap.kubeconfig
  2. bootstrap .kubeconfig 파일에서 user-data.txt cloud-init 파일을 생성합니다.

    $ cat <<EOF > user-data.txt
    #cloud-config
    write_files:
    - path: /root/openshift_bootstrap/openshift_settings.yaml
      owner: 'root:root'
      permissions: '0640'
      content: |
        openshift_node_config_name: node-config-compute
    - path: /etc/origin/node/bootstrap.kubeconfig
      owner: 'root:root'
      permissions: '0640'
      encoding: b64
      content: |
        $(base64 ~/bootstrap.kubeconfig | sed '2,$s/^/    /')
    
    runcmd:
    - [ ansible-playbook, /root/openshift_bootstrap/bootstrap.yml]
    - [ systemctl, restart, systemd-hostnamed]
    - [ systemctl, restart, NetworkManager]
    - [ systemctl, enable, atomic-openshift-node]
    - [ systemctl, start, atomic-openshift-node]
    EOF
  3. 시작 구성 템플릿을 AWS S3 버킷에 업로드합니다.
  4. AWS CLI를 사용하여 시작 구성을 생성합니다.

    $ aws autoscaling create-launch-configuration \
        --launch-configuration-name mycluster-LC \ 1
        --region us-east-1 \ 2
        --image-id ami-987654321 \ 3
        --instance-type m4.large \ 4
        --security-groups sg-12345678 \ 5
        --template-url https://s3-.amazonaws.com/.../yourtemplate.json \  6
        --key-name production-key \ 7
    1
    시작 구성 이름을 지정합니다.
    2
    이미지를 시작할 리전을 지정합니다.
    3
    생성한 기본 이미지 AMI를 지정합니다.
    4
    시작할 인스턴스 유형을 지정합니다.
    5
    시작된 이미지에 연결할 보안 그룹을 지정합니다.
    6
    업로드한 시작 구성 템플릿을 지정합니다.
    7
    SSH 키 쌍 이름을 지정합니다.
    참고

    템플릿을 인코딩하기 전에 16KB 미만인 경우 --template-url을 --user- data 로 대체하여 AWS CLI를 사용하여 제공할 수 있습니다.

  5. AWS CLI를 사용하여 자동 확장 그룹을 생성합니다.

    $ aws autoscaling create-auto-scaling-group \
          --auto-scaling-group-name mycluster-ASG \ 1
          --launch-configuration-name mycluster-LC \ 2
          --min-size 1 \ 3
          --max-size 6 \ 4
          --vpc-zone-identifier subnet-12345678 \ 5
          --tags ResourceId=mycluster-ASG,ResourceType=auto-scaling-group,Key=Name,Value=mycluster-ASG-node,PropagateAtLaunch=true ResourceId=mycluster-ASG,ResourceType=auto-scaling-group,Key=kubernetes.io/cluster/mycluster,Value=true,PropagateAtLaunch=true ResourceId=mycluster-ASG,ResourceType=auto-scaling-group,Key=k8s.io/cluster-autoscaler/node-template/label/node-role.kubernetes.io/compute,Value=true,PropagateAtLaunch=true 6
    1
    자동 확장기 배포를 배포할 때 사용하는 자동 확장 그룹의 이름을 지정합니다.
    2
    생성한 시작 구성의 이름을 지정합니다.
    3
    자동 확장기에서 유지 관리하는 최소 노드 수를 지정합니다. 하나 이상의 노드가 필요합니다.
    4
    확장 그룹이 확장할 수 있는 최대 노드 수를 지정합니다.
    5
    클러스터와 동일한 서브넷인 VPC subnet-id를 지정합니다.
    6
    자동 확장 그룹 태그가 시작될 때 노드로 전파되도록 이 문자열을 지정합니다.