文件 AWS SDK 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-arnarn:aws:iam::111122223333:role/role-name
\ --fargate-profile-namemy-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-arnarn:aws:iam::111122223333:role/role-name
\ --fargate-profile-namemy-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:為具有命名空間和標籤的選取器建立 EKS Fargate 設定檔,以及要啟動 Pod 的子網路 IDs。
下列
create-fargate-profile
範例會為具有命名空間和標籤的選取器建立 EKS Fargate 設定檔,以及要啟動 Pod 的子網路 IDs。aws eks create-fargate-profile \ --cluster-name
my-eks-cluster
\ --pod-execution-role-arnarn:aws:iam::111122223333:role/role-name
\ --fargate-profile-namemy-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:為具有多個命名空間和標籤的選取器建立 EKS Fargate 設定檔,以及要在其中啟動 Pod 的子網路 IDs
下列
create-fargate-profile
範例會為具有多個命名空間和標籤的選取器建立 EKS Fargate 設定檔,以及用來啟動 Pod 的子網路 IDs。aws eks create-fargate-profile \ --cluster-name
my-eks-cluster
\ --pod-execution-role-arnarn:aws:iam::111122223333:role/role-name
\ --fargate-profile-namemy-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:使用用於命名空間和標籤的萬用字元選取器建立 EKS Fargate 設定檔,以及用來啟動 Pod 的子網路 IDs
下列
create-fargate-profile
範例會為具有多個命名空間和標籤的選取器建立 EKS Fargate 設定檔,以及用來啟動 Pod 的子網路 IDs。aws eks create-fargate-profile \ --cluster-name
my-eks-cluster
\ --pod-execution-role-arnarn:aws:iam::111122223333:role/role-name
\ --fargate-profile-namemy-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 設定檔。
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 CreateFargateProfile
。
-
- PowerShell
-
- for PowerShell 工具
-
範例 1:此 cmdlet 會為您的 Amazon EKS 叢集建立 AWS Fargate 設定檔。叢集中必須至少有一個 Fargate 設定檔,才能在 Fargate 基礎設施上排程 Pod。
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 詳細資訊,請參閱 AWS Tools for PowerShell Cmdlet 參考中的 CreateFargateProfile。
-