EKS Fargate 지원 - Eksctl 사용 설명서

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

EKS Fargate 지원

AWS Fargate는 컨테이너를 실행할 수 있는 Amazon ECS용 관리형 컴퓨팅 엔진입니다. Fargate에서는 서버 또는 클러스터를 관리할 필요가 없습니다.

Amazon EKS는 이제 AWS Fargate에서 포드를 시작할 수 있습니다. 따라서 포드의 인프라를 프로비저닝하거나 관리하는 방법에 대해 걱정할 필요가 없으며 AWS에서 성능이 뛰어나고 가용성이 높은 Kubernetes 애플리케이션을 더 쉽게 빌드하고 실행할 수 있습니다.

Fargate를 지원하는 클러스터 생성

다음을 사용하여 Fargate를 지원하는 클러스터를 추가할 수 있습니다.

eksctl create cluster --fargate [ℹ] eksctl version 0.11.0 [ℹ] using region ap-northeast-1 [ℹ] setting availability zones to [ap-northeast-1a ap-northeast-1d ap-northeast-1c] [ℹ] subnets for ap-northeast-1a - public:192.168.0.0/19 private:192.168.96.0/19 [ℹ] subnets for ap-northeast-1d - public:192.168.32.0/19 private:192.168.128.0/19 [ℹ] subnets for ap-northeast-1c - public:192.168.64.0/19 private:192.168.160.0/19 [ℹ] nodegroup "ng-dba9d731" will use "ami-02e124a380df41614" [AmazonLinux2/1.14] [ℹ] using Kubernetes version 1.14 [ℹ] creating EKS cluster "ridiculous-painting-1574859263" in "ap-northeast-1" region [ℹ] will create 2 separate CloudFormation stacks for cluster itself and the initial nodegroup [ℹ] if you encounter any issues, check CloudFormation console or try 'eksctl utils describe-stacks --region=ap-northeast-1 --cluster=ridiculous-painting-1574859263' [ℹ] CloudWatch logging will not be enabled for cluster "ridiculous-painting-1574859263" in "ap-northeast-1" [ℹ] you can enable it with 'eksctl utils update-cluster-logging --enable-types={SPECIFY-YOUR-LOG-TYPES-HERE (e.g. all)} --region=ap-northeast-1 --cluster=ridiculous-painting-1574859263' [ℹ] Kubernetes API endpoint access will use default of {publicAccess=true, privateAccess=false} for cluster "ridiculous-painting-1574859263" in "ap-northeast-1" [ℹ] 2 sequential tasks: { create cluster control plane "ridiculous-painting-1574859263", create nodegroup "ng-dba9d731" } [ℹ] building cluster stack "eksctl-ridiculous-painting-1574859263-cluster" [ℹ] deploying stack "eksctl-ridiculous-painting-1574859263-cluster" [ℹ] building nodegroup stack "eksctl-ridiculous-painting-1574859263-nodegroup-ng-dba9d731" [ℹ] --nodes-min=2 was set automatically for nodegroup ng-dba9d731 [ℹ] --nodes-max=2 was set automatically for nodegroup ng-dba9d731 [ℹ] deploying stack "eksctl-ridiculous-painting-1574859263-nodegroup-ng-dba9d731" [✔] all EKS cluster resources for "ridiculous-painting-1574859263" have been created [✔] saved kubeconfig as "/Users/marc/.kube/config" [ℹ] adding identity "arn:aws:iam::123456789012:role/eksctl-ridiculous-painting-157485-NodeInstanceRole-104DXUJOFDPO5" to auth ConfigMap [ℹ] nodegroup "ng-dba9d731" has 0 node(s) [ℹ] waiting for at least 2 node(s) to become ready in "ng-dba9d731" [ℹ] nodegroup "ng-dba9d731" has 2 node(s) [ℹ] node "ip-192-168-27-156.ap-northeast-1.compute.internal" is ready [ℹ] node "ip-192-168-95-177.ap-northeast-1.compute.internal" is ready [ℹ] creating Fargate profile "default" on EKS cluster "ridiculous-painting-1574859263" [ℹ] created Fargate profile "default" on EKS cluster "ridiculous-painting-1574859263" [ℹ] kubectl command should work with "/Users/marc/.kube/config", try 'kubectl get nodes' [✔] EKS cluster "ridiculous-painting-1574859263" in "ap-northeast-1" region is ready

이 명령은 클러스터와 Fargate 프로파일을 생성했습니다. 이 프로필에는 AWS가 Fargate에서 포드를 인스턴스화하는 데 필요한 특정 정보가 포함되어 있습니다. 예를 들면 다음과 같습니다.

  • 포드 실행 역할은 포드를 실행하는 데 필요한 권한과 포드를 실행하는 네트워킹 위치(서브넷)를 정의합니다. 이를 통해 동일한 네트워킹 및 보안 권한을 여러 Fargate 포드에 적용할 수 있으며 클러스터의 기존 포드를 Fargate로 더 쉽게 마이그레이션할 수 있습니다.

  • Fargate에서 실행해야 하는 포드를 정의하는 선택기입니다. 이는 namespace 및 로 구성됩니다labels.

프로파일이 지정되지 않았지만 --fargate 기본 Fargate 프로파일로 Fargate에 대한 지원이 활성화된 경우. 이 프로필은 defaultkube-system 네임스페이스를 대상으로 하므로 해당 네임스페이스의 포드는 Fargate에서 실행됩니다.

생성된 Fargate 프로필은 다음 명령을 사용하여 확인할 수 있습니다.

eksctl get fargateprofile --cluster ridiculous-painting-1574859263 -o yaml - name: fp-default podExecutionRoleARN: arn:aws:iam::123456789012:role/eksctl-ridiculous-painting-1574859263-ServiceRole-EIFQOH0S1GE7 selectors: - namespace: default - namespace: kube-system subnets: - subnet-0b3a5522f3b48a742 - subnet-0c35f1497067363f3 - subnet-0a29aa00b25082021

선택기에 대한 자세한 내용은 Fargate 프로파일 설계를 참조하세요.

구성 파일을 사용하여 Fargate를 지원하는 클러스터 생성

다음 구성 파일은 EC2 m5.large 인스턴스 1개와 Fargate 프로파일 2개로 구성된 노드 그룹을 모두 포함하는 EKS 클러스터를 선언합니다. defaultkube-system 네임스페이스에 정의된 모든 포드는 Fargate에서 실행됩니다. 레이블도 있는 dev 네임스페이스의 모든 포드도 Fargate에서 실행dev=passed됩니다. 다른 모든 포드는의 노드에 예약됩니다ng-1.

# An example of ClusterConfig with a normal nodegroup and a Fargate profile. --- apiVersion: eksctl.io/v1alpha5 kind: ClusterConfig metadata: name: fargate-cluster region: ap-northeast-1 nodeGroups: - name: ng-1 instanceType: m5.large desiredCapacity: 1 fargateProfiles: - name: fp-default selectors: # All workloads in the "default" Kubernetes namespace will be # scheduled onto Fargate: - namespace: default # All workloads in the "kube-system" Kubernetes namespace will be # scheduled onto Fargate: - namespace: kube-system - name: fp-dev selectors: # All workloads in the "dev" Kubernetes namespace matching the following # label selectors will be scheduled onto Fargate: - namespace: dev labels: env: dev checks: passed
eksctl create cluster -f cluster-fargate.yaml [ℹ] eksctl version 0.11.0 [ℹ] using region ap-northeast-1 [ℹ] setting availability zones to [ap-northeast-1c ap-northeast-1a ap-northeast-1d] [ℹ] subnets for ap-northeast-1c - public:192.168.0.0/19 private:192.168.96.0/19 [ℹ] subnets for ap-northeast-1a - public:192.168.32.0/19 private:192.168.128.0/19 [ℹ] subnets for ap-northeast-1d - public:192.168.64.0/19 private:192.168.160.0/19 [ℹ] nodegroup "ng-1" will use "ami-02e124a380df41614" [AmazonLinux2/1.14] [ℹ] using Kubernetes version 1.14 [ℹ] creating EKS cluster "fargate-cluster" in "ap-northeast-1" region with Fargate profile and 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=ap-northeast-1 --cluster=fargate-cluster' [ℹ] CloudWatch logging will not be enabled for cluster "fargate-cluster" in "ap-northeast-1" [ℹ] you can enable it with 'eksctl utils update-cluster-logging --enable-types={SPECIFY-YOUR-LOG-TYPES-HERE (e.g. all)} --region=ap-northeast-1 --cluster=fargate-cluster' [ℹ] Kubernetes API endpoint access will use default of {publicAccess=true, privateAccess=false} for cluster "fargate-cluster" in "ap-northeast-1" [ℹ] 2 sequential tasks: { create cluster control plane "fargate-cluster", create nodegroup "ng-1" } [ℹ] building cluster stack "eksctl-fargate-cluster-cluster" [ℹ] deploying stack "eksctl-fargate-cluster-cluster" [ℹ] building nodegroup stack "eksctl-fargate-cluster-nodegroup-ng-1" [ℹ] --nodes-min=1 was set automatically for nodegroup ng-1 [ℹ] --nodes-max=1 was set automatically for nodegroup ng-1 [ℹ] deploying stack "eksctl-fargate-cluster-nodegroup-ng-1" [✔] all EKS cluster resources for "fargate-cluster" have been created [✔] saved kubeconfig as "/home/user1/.kube/config" [ℹ] adding identity "arn:aws:iam::123456789012:role/eksctl-fargate-cluster-nod-NodeInstanceRole-42Q80B2Z147I" to auth ConfigMap [ℹ] nodegroup "ng-1" has 0 node(s) [ℹ] waiting for at least 1 node(s) to become ready in "ng-1" [ℹ] nodegroup "ng-1" has 1 node(s) [ℹ] node "ip-192-168-71-83.ap-northeast-1.compute.internal" is ready [ℹ] creating Fargate profile "fp-default" on EKS cluster "fargate-cluster" [ℹ] created Fargate profile "fp-default" on EKS cluster "fargate-cluster" [ℹ] creating Fargate profile "fp-dev" on EKS cluster "fargate-cluster" [ℹ] created Fargate profile "fp-dev" on EKS cluster "fargate-cluster" [ℹ] "coredns" is now schedulable onto Fargate [ℹ] "coredns" is now scheduled onto Fargate [ℹ] "coredns" is now scheduled onto Fargate [ℹ] "coredns" pods are now scheduled onto Fargate [ℹ] kubectl command should work with "/home/user1/.kube/config", try 'kubectl get nodes' [✔] EKS cluster "fargate-cluster" in "ap-northeast-1" region is ready

Fargate 프로파일 설계

각 선택기 항목에는 최대 2개의 구성 요소, 즉 네임스페이스와 키-값 페어 목록이 있습니다. 선택기 항목을 생성하려면 네임스페이스 구성 요소만 필요합니다. 선택기 항목과 일치하려면 모든 규칙(네임스페이스, 키 값 페어)이 포드에 적용되어야 합니다. 포드는 프로필에서 실행할 선택기 항목 하나와만 일치하면 됩니다. 선택기 필드의 모든 조건과 일치하는 모든 포드는 Fargate에서 실행되도록 예약됩니다. 화이트리스트에 등록된 네임스페이스 중 하나와 일치하지 않지만 사용자가 스케줄러를 수동으로 설정한 모든 포드: fargate-scheduler 필드는 Fargate에서 실행할 권한이 없으므로 보류 중 상태로 멈춥니다.

프로필은 다음 요구 사항을 충족해야 합니다.

  • 프로필당 하나의 선택기가 필수입니다.

  • 각 선택기에는 네임스페이스가 포함되어야 합니다. 레이블은 선택 사항입니다.

예: Fargate에서 워크로드 예약

위에서 언급한 예제에 대해 Fargate에서 포드를 예약하려면 예를 들어 라는 네임스페이스를 생성하고 여기에 워크로드를 dev 배포할 수 있습니다.

kubectl create namespace dev namespace/dev created kubectl run nginx --image=nginx --restart=Never --namespace dev pod/nginx created kubectl get pods --all-namespaces --output wide NAMESPACE NAME READY STATUS AGE IP NODE dev nginx 1/1 Running 75s 192.168.183.140 fargate-ip-192-168-183-140.ap-northeast-1.compute.internal kube-system aws-node-44qst 1/1 Running 21m 192.168.70.246 ip-192-168-70-246.ap-northeast-1.compute.internal kube-system aws-node-4vr66 1/1 Running 21m 192.168.23.122 ip-192-168-23-122.ap-northeast-1.compute.internal kube-system coredns-699bb99bf8-84x74 1/1 Running 26m 192.168.2.95 ip-192-168-23-122.ap-northeast-1.compute.internal kube-system coredns-699bb99bf8-f6x6n 1/1 Running 26m 192.168.90.73 ip-192-168-70-246.ap-northeast-1.compute.internal kube-system kube-proxy-brxhg 1/1 Running 21m 192.168.23.122 ip-192-168-23-122.ap-northeast-1.compute.internal kube-system kube-proxy-zd7s8 1/1 Running 21m 192.168.70.246 ip-192-168-70-246.ap-northeast-1.compute.internal

마지막 kubectl get pods 명령의 출력에서 포드가 nginx 라는 노드에 배포된 것을 확인할 수 있습니다fargate-ip-192-168-183-140.ap-northeast-1.compute.internal.

Fargate 프로필 관리

Fargate에 Kubernetes 워크로드를 배포하려면 EKS에 Fargate 프로필이 필요합니다. 위 예제와 같이 클러스터를 생성할 때 eksctl는 기본 프로필을 생성하여 이를 처리합니다. 이미 존재하는 클러스터를 고려할 때 eksctl create fargateprofile 명령을 사용하여 Fargate 프로파일을 생성할 수도 있습니다.

참고

이 작업은 EKS 플랫폼 버전 eks.5 이상에서 실행되는 클러스터에서만 지원됩니다.

참고

기존가 0.11.0 eksctl 이전 버전으로 생성된 경우 Fargate 프로파일을 생성하기 eksctl upgrade cluster 전에를 실행해야 합니다.

eksctl create fargateprofile --namespace dev --cluster fargate-example-cluster [ℹ] creating Fargate profile "fp-9bfc77ad" on EKS cluster "fargate-example-cluster" [ℹ] created Fargate profile "fp-9bfc77ad" on EKS cluster "fargate-example-cluster"

생성할 Fargate 프로필의 이름을 지정할 수도 있습니다. 이 이름은 접두사 로 시작해서는 안 됩니다eks-.

eksctl create fargateprofile --namespace dev --cluster fargate-example-cluster --name fp-development [ℹ] created Fargate profile "fp-development" on EKS cluster "fargate-example-cluster"

CLI 플래그와 함께이 명령을 사용하면 eksctl은 간단한 선택기를 사용하여 단일 Fargate 프로파일만 생성할 수 있습니다. 네임스페이스가 더 많은 경우와 같이 더 복잡한 선택기의 경우 eksctl은 구성 파일 사용을 지원합니다.

apiVersion: eksctl.io/v1alpha5 kind: ClusterConfig metadata: name: fargate-example-cluster region: ap-northeast-1 fargateProfiles: - name: fp-default selectors: # All workloads in the "default" Kubernetes namespace will be # scheduled onto Fargate: - namespace: default # All workloads in the "kube-system" Kubernetes namespace will be # scheduled onto Fargate: - namespace: kube-system - name: fp-dev selectors: # All workloads in the "dev" Kubernetes namespace matching the following # label selectors will be scheduled onto Fargate: - namespace: dev labels: env: dev checks: passed
eksctl create fargateprofile -f fargate-example-cluster.yaml [ℹ] creating Fargate profile "fp-default" on EKS cluster "fargate-example-cluster" [ℹ] created Fargate profile "fp-default" on EKS cluster "fargate-example-cluster" [ℹ] creating Fargate profile "fp-dev" on EKS cluster "fargate-example-cluster" [ℹ] created Fargate profile "fp-dev" on EKS cluster "fargate-example-cluster" [ℹ] "coredns" is now scheduled onto Fargate [ℹ] "coredns" pods are now scheduled onto Fargate

클러스터에서 기존 Fargate 프로파일을 보려면:

eksctl get fargateprofile --cluster fargate-example-cluster NAME SELECTOR_NAMESPACE SELECTOR_LABELS POD_EXECUTION_ROLE_ARN SUBNETS fp-9bfc77ad dev <none> arn:aws:iam::123456789012:role/eksctl-fargate-example-cluster-ServiceRole-1T5F78E5FSH79 subnet-00adf1d8c99f83381,subnet-04affb163ffab17d4,subnet-035b34379d5ef5473

그리고 yaml 형식으로 보려면:

eksctl get fargateprofile --cluster fargate-example-cluster -o yaml - name: fp-9bfc77ad podExecutionRoleARN: arn:aws:iam::123456789012:role/eksctl-fargate-example-cluster-ServiceRole-1T5F78E5FSH79 selectors: - namespace: dev subnets: - subnet-00adf1d8c99f83381 - subnet-04affb163ffab17d4 - subnet-035b34379d5ef5473

또는 json 형식:

eksctl get fargateprofile --cluster fargate-example-cluster -o json [ { "name": "fp-9bfc77ad", "podExecutionRoleARN": "arn:aws:iam::123456789012:role/eksctl-fargate-example-cluster-ServiceRole-1T5F78E5FSH79", "selectors": [ { "namespace": "dev" } ], "subnets": [ "subnet-00adf1d8c99f83381", "subnet-04affb163ffab17d4", "subnet-035b34379d5ef5473" ] } ]

Fargate 프로파일은 설계상 변경할 수 없습니다. 무언가를 변경하려면 원하는 변경 사항이 있는 새 Fargate 프로필을 생성하고 다음 예제와 같이 eksctl delete fargateprofile 명령을 사용하여 이전 프로필을 삭제합니다.

eksctl delete fargateprofile --cluster fargate-example-cluster --name fp-9bfc77ad --wait 2019-11-27T19:04:26+09:00 [ℹ] deleting Fargate profile "fp-9bfc77ad" ClusterName: "fargate-example-cluster", FargateProfileName: "fp-9bfc77ad" }

프로필 삭제는 최대 몇 분 정도 걸릴 수 있는 프로세스입니다. --wait 플래그를 지정하지 않으면 eksctl는 프로필이 삭제될 것으로 예상하고 AWS API 요청이 전송되는 즉시를 반환합니다. 프로필이 성공적으로 삭제될 때까지 eksctl 기다리려면 위 예제와 --wait 같이를 사용합니다.

참조 자료