AWS SDK 또는 CreateFargateProfile CLI와 함께 사용 - AWS SDK 코드 예제

AWS 문서 AWS SDK 예제 리포지토리에 더 많은 SDK 예제가 있습니다. GitHub

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

AWS SDK 또는 CreateFargateProfile CLI와 함께 사용

다음 코드 예제는 CreateFargateProfile의 사용 방법을 보여줍니다.

CLI
AWS CLI

예 1: 네임스페이스가 있는 선택기에 대한 EKS Fargate 프로필 생성

다음 create-fargate-profile 예제에서는 네임스페이스가 있는 선택기에 대한 EKS Fargate 프로필을 생성합니다.

aws eks create-fargate-profile \ --cluster-name my-eks-cluster \ --pod-execution-role-arn arn:aws:iam::111122223333:role/role-name \ --fargate-profile-name my-fargate-profile \ --selectors '[{"namespace": "default"}]'

출력:

{ "fargateProfile": { "fargateProfileName": "my-fargate-profile", "fargateProfileArn": "arn:aws:eks:us-east-2:111122223333:fargateprofile/my-eks-cluster/my-fargate-profile/a2c72bca-318e-abe8-8ed1-27c6d4892e9e", "clusterName": "my-eks-cluster", "createdAt": "2024-03-19T12:38:47.368000-04:00", "podExecutionRoleArn": "arn:aws:iam::111122223333:role/role-name", "subnets": [ "subnet-09d912bb63ef21b9a", "subnet-04ad87f71c6e5ab4d", "subnet-0e2907431c9988b72" ], "selectors": [ { "namespace": "default" } ], "status": "CREATING", "tags": {} } }

자세한 내용은 Amazon EKS 사용 AWS 설명서의 Fargate 프로필 - Fargate 프로필 생성을 참조하십시오.

예 2: 네임스페이스와 레이블이 있는 선택기에 대한 EKS Fargate 프로필 생성

다음 create-fargate-profile 예제에서는 네임스페이스와 레이블이 있는 선택기에 대한 EKS Fargate 프로필을 만듭니다.

aws eks create-fargate-profile \ --cluster-name my-eks-cluster \ --pod-execution-role-arn arn:aws:iam::111122223333:role/role-name \ --fargate-profile-name my-fargate-profile \ --selectors '[{"namespace": "default", "labels": {"labelname1": "labelvalue1"}}]'

출력:

{ "fargateProfile": { "fargateProfileName": "my-fargate-profile", "fargateProfileArn": "arn:aws:eks:us-east-2:111122223333:fargateprofile/my-eks-cluster/my-fargate-profile/88c72bc7-e8a4-fa34-44e4-2f1397224bb3", "clusterName": "my-eks-cluster", "createdAt": "2024-03-19T12:33:48.125000-04:00", "podExecutionRoleArn": "arn:aws:iam::111122223333:role/role-name", "subnets": [ "subnet-09d912bb63ef21b9a", "subnet-04ad87f71c6e5ab4d", "subnet-0e2907431c9988b72" ], "selectors": [ { "namespace": "default", "labels": { "labelname1": "labelvalue1" } } ], "status": "CREATING", "tags": {} } }

자세한 내용은 Amazon EKS 사용 AWS 설명서의 Fargate 프로필 - Fargate 프로필 생성을 참조하십시오.

예 3: 네임스페이스와 레이블, 그리고 파드를 시작할 서브넷의 ID가 있는 셀렉터용 EKS Fargate 프로필을 생성하십시오.

다음 create-fargate-profile 예시는 네임스페이스와 레이블이 있는 셀렉터용 EKS Fargate Profile을 생성하고, 파드를 시작할 서브넷의 ID를 생성한다.

aws eks create-fargate-profile \ --cluster-name my-eks-cluster \ --pod-execution-role-arn arn:aws:iam::111122223333:role/role-name \ --fargate-profile-name my-fargate-profile \ --selectors '[{"namespace": "default", "labels": {"labelname1": "labelvalue1"}}]' \ --subnets '["subnet-09d912bb63ef21b9a", "subnet-04ad87f71c6e5ab4d", "subnet-0e2907431c9988b72"]'

출력:

{ "fargateProfile": { "fargateProfileName": "my-fargate-profile", "fargateProfileArn": "arn:aws:eks:us-east-2:111122223333:fargateprofile/my-eks-cluster/my-fargate-profile/e8c72bc8-e87b-5eb6-57cb-ed4fe57577e3", "clusterName": "my-eks-cluster", "createdAt": "2024-03-19T12:35:58.640000-04:00", "podExecutionRoleArn": "arn:aws:iam::111122223333:role/role-name", "subnets": [ "subnet-09d912bb63ef21b9a", "subnet-04ad87f71c6e5ab4d", "subnet-0e2907431c9988b72" ], "selectors": [ { "namespace": "default", "labels": { "labelname1": "labelvalue1" } } ], "status": "CREATING", "tags": {} } }

자세한 내용은 Amazon EKS 사용 AWS 설명서의 Fargate 프로필 - Fargate 프로필 생성을 참조하십시오.

예 4: 파드를 시작할 서브넷의 ID와 함께 여러 네임스페이스와 레이블이 있는 셀렉터용 EKS Fargate 프로필 생성

다음 create-fargate-profile 예시는 파드를 시작할 서브넷의 ID와 함께 여러 네임스페이스와 레이블이 있는 셀렉터용 EKS Fargate Profile을 생성합니다.

aws eks create-fargate-profile \ --cluster-name my-eks-cluster \ --pod-execution-role-arn arn:aws:iam::111122223333:role/role-name \ --fargate-profile-name my-fargate-profile \ --selectors '[{"namespace": "default1", "labels": {"labelname1": "labelvalue1", "labelname2": "labelvalue2"}}, {"namespace": "default2", "labels": {"labelname1": "labelvalue1", "labelname2": "labelvalue2"}}]' \ --subnets '["subnet-09d912bb63ef21b9a", "subnet-04ad87f71c6e5ab4d", "subnet-0e2907431c9988b72"]' \ --tags '{"eks-fargate-profile-key-1": "value-1" , "eks-fargate-profile-key-2": "value-2"}'

출력:

{ "fargateProfile": { "fargateProfileName": "my-fargate-profile", "fargateProfileArn": "arn:aws:eks:us-east-2:111122223333:fargateprofile/my-eks-cluster/my-fargate-profile/4cc72bbf-b766-8ee6-8d29-e62748feb3cd", "clusterName": "my-eks-cluster", "createdAt": "2024-03-19T12:15:55.271000-04:00", "podExecutionRoleArn": "arn:aws:iam::111122223333:role/role-name", "subnets": [ "subnet-09d912bb63ef21b9a", "subnet-04ad87f71c6e5ab4d", "subnet-0e2907431c9988b72" ], "selectors": [ { "namespace": "default1", "labels": { "labelname2": "labelvalue2", "labelname1": "labelvalue1" } }, { "namespace": "default2", "labels": { "labelname2": "labelvalue2", "labelname1": "labelvalue1" } } ], "status": "CREATING", "tags": { "eks-fargate-profile-key-2": "value-2", "eks-fargate-profile-key-1": "value-1" } } }

자세한 내용은 Amazon EKS 사용 AWS 설명서의 Fargate 프로필 - Fargate 프로필 생성을 참조하십시오.

예 5: 네임스페이스 및 레이블에 대한 와일드카드 선택기를 사용하고 파드를 시작할 서브넷의 ID를 사용하여 EKS Fargate Profile 생성

다음 create-fargate-profile 예시는 파드를 시작할 서브넷의 ID와 함께 여러 네임스페이스와 레이블이 있는 셀렉터용 EKS Fargate Profile을 생성합니다.

aws eks create-fargate-profile \ --cluster-name my-eks-cluster \ --pod-execution-role-arn arn:aws:iam::111122223333:role/role-name \ --fargate-profile-name my-fargate-profile \ --selectors '[{"namespace": "prod*", "labels": {"labelname*?": "*value1"}}, {"namespace": "*dev*", "labels": {"labelname*?": "*value*"}}]' \ --subnets '["subnet-09d912bb63ef21b9a", "subnet-04ad87f71c6e5ab4d", "subnet-0e2907431c9988b72"]' \ --tags '{"eks-fargate-profile-key-1": "value-1" , "eks-fargate-profile-key-2": "value-2"}'

출력:

{ "fargateProfile": { "fargateProfileName": "my-fargate-profile", "fargateProfileArn": "arn:aws:eks:us-east-2:111122223333:fargateprofile/my-eks-cluster/my-fargate-profile/e8c72bd6-5966-0bfe-b77b-1802893e5a6f", "clusterName": "my-eks-cluster", "createdAt": "2024-03-19T13:05:20.550000-04:00", "podExecutionRoleArn": "arn:aws:iam::111122223333:role/role-name", "subnets": [ "subnet-09d912bb63ef21b9a", "subnet-04ad87f71c6e5ab4d", "subnet-0e2907431c9988b72" ], "selectors": [ { "namespace": "prod*", "labels": { "labelname*?": "*value1" } }, { "namespace": "*dev*", "labels": { "labelname*?": "*value*" } } ], "status": "CREATING", "tags": { "eks-fargate-profile-key-2": "value-2", "eks-fargate-profile-key-1": "value-1" } } }

자세한 내용은 Amazon EKS 사용 AWS 설명서의 Fargate 프로필 - Fargate 프로필 생성을 참조하십시오.

PowerShell
도구: PowerShell

예 1: 이 cmdlet은 Amazon EKS 클러스터를 위한 AWS Fargate 프로필을 생성합니다. Fargate 인프라에서 포드를 스케줄링하려면 클러스터에 Fargate 프로필이 하나 이상 있어야 합니다.

New-EKSFargateProfile -FargateProfileName EKSFargateProfile -ClusterName TEST -Subnet "subnet-02f6ff500ff2067a0", "subnet-0cd976f08d5fbfaae" -PodExecutionRoleArn arn:aws:iam::012345678912:role/AmazonEKSFargatePodExecutionRole -Selector @{Namespace="default"}

출력:

ClusterName : TEST CreatedAt : 12/26/2019 12:38:21 PM FargateProfileArn : arn:aws:eks:us-east-2:012345678912:fargateprofile/TEST/EKSFargateProfile/20b7a11b-8292-41c1-bc56-ffa5e60f6224 FargateProfileName : EKSFargateProfile PodExecutionRoleArn : arn:aws:iam::012345678912:role/AmazonEKSFargatePodExecutionRole Selectors : {Amazon.EKS.Model.FargateProfileSelector} Status : CREATING Subnets : {subnet-0cd976f08d5fbfaae, subnet-02f6ff500ff2067a0} Tags : {}
  • API에 대한 자세한 내용은 Cmdlet 참조를 참조하십시오 CreateFargateProfile.AWS Tools for PowerShell