인터넷에 액세스할 필요가 없는 Amazon EKS 클러스터 및 노드 그룹을 생성하려면 어떻게 해야 하나요?

4분 분량
0

PrivateOnly 네트워킹을 사용하여 Amazon Elastic Kubernetes Service(Amazon EKS) 클러스터 및 노드 그룹을 생성하려고 합니다. 인터넷 게이트웨이 또는 NAT(Network Address Translation) 게이트웨이를 사용하고 싶지 않습니다.

간략한 설명

AWS PrivateLink를 사용하여 인터넷 라우팅을 사용하지 않고 Amazon EKS 클러스터와 해당 노드 그룹을 생성할 수 있습니다.

해결 방법

Amazon EKS 클러스터에 대한 Amazon Virtual Private Cloud(Amazon VPC) 생성

1.    다음 템플릿을 사용하여 AWS CloudFormation 스택을 생성합니다.

https://amazon-eks.s3.us-west-2.amazonaws.com/cloudformation/2020-06-10/amazon-eks-fully-private-vpc.yaml

이 스택은 필요한 서비스에 대해 세 개의 PrivateOnly 서브넷과 VPC 엔드포인트가 있는 VPC를 생성합니다. PrivateOnly 서브넷에는 기본 로컬 라우팅이 있고 인터넷에 액세스할 수 없는 라우팅 테이블이 있습니다.

중요: AWS CloudFormation 템플릿은 전체 액세스 정책으로 VPC 엔드포인트를 생성하지만, 요구 사항에 따라 정책을 추가로 제한할 수 있습니다.

팁: 스택이 생성된 후 모든 VPC 엔드포인트를 검토하려면 Amazon VPC 콘솔을 열고 탐색 창에서 엔드포인트를 선택합니다.

2.    AWS CloudFormation 콘솔을 엽니다.

3.    탐색 창에서 [스택]을 선택합니다.

4.    스택을 선택한 다음 출력(Outputs) 탭을 선택합니다. 이 탭에는 VPC ID를 포함해 나중에 필요한 서브넷에 대한 정보가 있습니다.

Amazon EKS 클러스터 구성 파일을 구성한 후 클러스터 및 노드 그룹 생성

1.    다음 구성 파일에서 Amazon EKS 클러스터에 대한 VPC 생성 섹션에서 생성한 AWS 리전과 PrivateOnly 서브넷 세 개를 업데이트합니다. 구성 파일에서 다른 속성을 수정하거나 속성을 추가할 수도 있습니다. 예를 들어 name, instanceType 또는 desiredCapacity를 업데이트할 수 있습니다.

구성 파일 예시

apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
  name: prod
  region: us-east-1   
nodeGroups:
  - name: ng-1
    instanceType: m5.xlarge
    desiredCapacity: 2
    privateNetworking: true
vpc:
  subnets:
    private:
      us-east-1a:
        id: "subnet-0111111111111111"
      us-east-1b:
        id: "subnet-0222222222222222"
      us-east-1c:
        id: "subnet-0333333333333333"
  clusterEndpoints:
    publicAccess:  true
    privateAccess: true

이전 구성 파일에서 nodeGroups에 대해 privateNetworkingtrue로 설정합니다. clusterEndpoint의 경우 privateAccesstrue로 설정합니다.

중요: eksctl 도구는 해결 작업에 필요하지 않습니다. 다른 도구 또는 Amazon EKS 콘솔을 사용하여 Amazon EKS 클러스터 및 노드를 생성할 수 있습니다. 하지만 다른 도구 또는 콘솔을 사용하여 노드를 생성하는 경우, 노드에 대한 부트스트랩 스크립트를 호출하는 동안 Amazon EKS 클러스터의 CA 인증서 및 API 서버 엔드포인트를 인수로 전달해야 합니다.

2.    1단계에서 업데이트된 구성 파일을 기반으로 Amazon EKS 클러스터 및 노드 그룹을 생성하려면 다음 명령을 실행합니다.

$ eksctl create cluster -f config.yaml

참고: 일부 eksctl 버전은 파일이client.authentication.k8s.io/v1alpha1을 나타낼 때 Kubeconfig 파일을 생성하는 동안 오류를 일으킬 수 있습니다. update-kubeconfig 명령을 실행하여 Kubeconfig 파일을 업데이트할 수 있습니다(최신AWS CLI 버전을 사용 중인지 확인하세요).

앞의 명령은 인터넷에 액세스할 수 없는 AWS PrivateLink를 사용하여 PrivateOnly 네트워크에서 Amazon EKS 클러스터 및 노드 그룹을 생성합니다. 이 프로세스에는 약 30분이 소요됩니다.

다음과 유사하게 출력됩니다.

Output
[ℹ]  eksctl version 0.21.0
[ℹ]  using region us-east-1
[✔]  using existing VPC (vpc-01234567) and subnets (private:[subnet-01111111111111111 subnet-02222222222222222 subnet-03333333333333333] public:[])
[!]  custom VPC/subnets will be used; if resulting cluster doesn't function as expected, make sure to review the configuration of VPC/subnets
[ℹ]  nodegroup "ng-1" will use "ami-0ee0652ac0722f0e3" [AmazonLinux2/1.16]
[ℹ]  using Kubernetes version 1.16
[ℹ]  creating EKS cluster "prod" in "us-east-1" region with un-managed nodes
[ℹ]  1 nodegroup (ng-1) was included (based on the include/exclude rules)
[ℹ]  will create a CloudFormation stack for cluster itself and 1 nodegroup stack(s)
[ℹ]  will create a CloudFormation stack for cluster itself and 0 managed nodegroup stack(s)
[ℹ]  if you encounter any issues, check CloudFormation console or try 'eksctl utils describe-stacks --region=us-east-1 --cluster=prod'
[ℹ]  CloudWatch logging will not be enabled for cluster "prod" in "us-east-1"
[ℹ]  you can enable it with 'eksctl utils update-cluster-logging --region=us-east-1 --cluster=prod'
[ℹ]  Kubernetes API endpoint access will use provided values {publicAccess=true, privateAccess=true} for cluster "prod" in "us-east-1"
[ℹ]  2 sequential tasks: { create cluster control plane "prod", 2 sequential sub-tasks: { update cluster VPC endpoint access configuration, create nodegroup "ng-1" } }
[ℹ]  building cluster stack "eksctl-prod-cluster"
[ℹ]  deploying stack "eksctl-prod-cluster"
[ℹ]  building nodegroup stack "eksctl-prod-nodegroup-ng-1"
[ℹ]  --nodes-min=2 was set automatically for nodegroup ng-1
[ℹ]  --nodes-max=2 was set automatically for nodegroup ng-1
[ℹ]  deploying stack "eksctl-prod-nodegroup-ng-1"
[✔]  all EKS cluster resources for "prod" have been created
[✔]  saved kubeconfig as "/Users/garpunee/.kube/config"
[ℹ]  adding identity "arn:aws:iam::444444444444:role/eksctl-prod-nodegroup-ng-1-NodeInstanceRole-H37FWX4H84GH" to auth ConfigMap
[ℹ]  nodegroup "ng-1" has 0 node(s)
[ℹ]  waiting for at least 2 node(s) to become ready in "ng-1"
[ℹ]  nodegroup "ng-1" has 2 node(s)
[ℹ]  node "ip-192-168-254-139.ec2.internal" is ready
[ℹ]  node "ip-192-168-60-191.ec2.internal" is ready
[ℹ]  kubectl command should work with "/Users/<>/.kube/config", try 'kubectl get nodes'
[✔]  EKS cluster "prod" in "us-east-1" region is ready

참고: AWS Management Console 또는 eksctl을 사용하여 클러스터 내에서 관리형 또는 비관리형 노드 그룹을 생성할 수도 있습니다. eksctl에 대한 자세한 내용은 Weaveworks 웹 사이트의 Managing nodegroups 섹션을 참조하세요.


관련 정보

클러스터 엔드포인트 액세스 수정

Using config files(eksctl)

AWS 공식
AWS 공식업데이트됨 2년 전
댓글 없음

관련 콘텐츠