Versione 5 (V5) del AWS Strumenti per PowerShell è stata rilasciata!
Per informazioni sulle modifiche sostanziali e sulla migrazione delle applicazioni, consulta la argomento sulla migrazione.
Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.
Esempi di Amazon EKS che utilizzano Tools per PowerShell V5
I seguenti esempi di codice mostrano come eseguire azioni e implementare scenari comuni utilizzando AWS Strumenti per PowerShell V5 con Amazon EKS.
Le azioni sono estratti di codice da programmi più grandi e devono essere eseguite nel contesto. Sebbene le azioni mostrino come richiamare le singole funzioni del servizio, è possibile visualizzarle contestualizzate negli scenari correlati.
Ogni esempio include un link al codice sorgente completo, in cui vengono fornite le istruzioni su come configurare ed eseguire il codice nel contesto.
Argomenti
Operazioni
L’esempio di codice seguente mostra come utilizzare Add-EKSResourceTag.
- Strumenti per PowerShell V5
-
Esempio 1: questo cmdlet associa i tag specificati a una risorsa con l’ARN di risorsa specificato.
Add-EKSResourceTag -ResourceArn "arn:aws:eks:us-west-2:012345678912:cluster/PROD" -Tag @{Name = "EKSPRODCLUSTER"}-
Per i dettagli sull'API, vedi TagResource nel AWS Strumenti per PowerShell Riferimento al cmdlet (V5).
-
L’esempio di codice seguente mostra come utilizzare Get-EKSCluster.
- Utensili per PowerShell V5
-
Esempio 1: questo cmdlet restituisce informazioni descrittive su un cluster Amazon EKS.
Get-EKSCluster -Name "PROD"Output:
Arn : arn:aws:eks:us-west-2:012345678912:cluster/PROD CertificateAuthority : Amazon.EKS.Model.Certificate ClientRequestToken : CreatedAt : 12/25/2019 6:46:17 AM Endpoint : https://669608765450FBBE54D1D78A3D71B72C.gr8.us-west-2.eks.amazonaws.com Identity : Amazon.EKS.Model.Identity Logging : Amazon.EKS.Model.Logging Name : PROD PlatformVersion : eks.7 ResourcesVpcConfig : Amazon.EKS.Model.VpcConfigResponse RoleArn : arn:aws:iam::012345678912:role/eks-iam-role Status : ACTIVE Tags : {} Version : 1.14-
Per i dettagli sull'API, vedi DescribeCluster nel AWS Strumenti per PowerShell Riferimento al cmdlet (V5).
-
L’esempio di codice seguente mostra come utilizzare Get-EKSClusterList.
- Utensili per PowerShell V5
-
Esempio 1: questo cmdlet elenca i cluster Amazon EKS nel tuo Account AWS nella regione specificata.
Get-EKSClusterListOutput:
PROD-
Per i dettagli sull'API, consulta ListClusters nel AWS Strumenti per PowerShell Riferimento al cmdlet (V5).
-
L’esempio di codice seguente mostra come utilizzare Get-EKSFargateProfile.
- Utensili per PowerShell V5
-
Esempio 1: questo cmdlet restituisce informazioni descrittive su un AWS Profilo Fargate.
Get-EKSFargateProfile -FargateProfileName "EKSFargate" -ClusterName "TEST"Output:
ClusterName : TEST CreatedAt : 12/26/2019 12:34:47 PM FargateProfileArn : arn:aws:eks:us-east-2:012345678912:fargateprofile/TEST/EKSFargate/42b7a119-e16b-a279-ce97-bdf303adec92 FargateProfileName : EKSFargate PodExecutionRoleArn : arn:aws:iam::012345678912:role/AmazonEKSFargatePodExecutionRole Selectors : {Amazon.EKS.Model.FargateProfileSelector} Status : ACTIVE Subnets : {subnet-0cd976f08d5fbfaae, subnet-02f6ff500ff2067a0} Tags : {}-
Per i dettagli sull'API, consulta DescribeFargateProfile nel AWS Strumenti per PowerShell Riferimento al cmdlet (V5).
-
L’esempio di codice seguente mostra come utilizzare Get-EKSFargateProfileList.
- Utensili per PowerShell V5
-
Esempio 1: questo cmdlet elenca i AWS Profili Fargate associati al cluster specificato nel tuo Account AWS nella regione specificata.
Get-EKSFargateProfileList -ClusterName "TEST"Output:
EKSFargate EKSFargateProfile-
Per i dettagli sull'API, consulta ListFargateProfiles nel AWS Strumenti per PowerShell Riferimento al cmdlet (V5).
-
L’esempio di codice seguente mostra come utilizzare Get-EKSNodegroup.
- Utensili per PowerShell V5
-
Esempio 1: questo cmdlet restituisce informazioni descrittive su un gruppo di nodi Amazon EKS.
Get-EKSNodegroup -NodegroupName "ProdEKSNodeGroup" -ClusterName "PROD"Output:
AmiType : AL2_x86_64 ClusterName : PROD CreatedAt : 12/25/2019 10:16:45 AM DiskSize : 40 Health : Amazon.EKS.Model.NodegroupHealth InstanceTypes : {t3.large} Labels : {} ModifiedAt : 12/25/2019 10:16:45 AM NodegroupArn : arn:aws:eks:us-west-2:012345678912:nodegroup/PROD/ProdEKSNodeGroup/7eb79e47-82b6-04d9-e984-95110db6fa85 NodegroupName : ProdEKSNodeGroup NodeRole : arn:aws:iam::012345678912:role/NodeInstanceRole ReleaseVersion : 1.14.7-20190927 RemoteAccess : Resources : ScalingConfig : Amazon.EKS.Model.NodegroupScalingConfig Status : CREATING Subnets : {subnet-0d1a9fff35efa7691, subnet-0a3f4928edbc224d4} Tags : {} Version : 1.14-
Per i dettagli sull'API, vedi DescribeNodegroup nel AWS Strumenti per PowerShell Riferimento al cmdlet (V5).
-
L’esempio di codice seguente mostra come utilizzare Get-EKSNodegroupList.
- Utensili per PowerShell V5
-
Esempio 1: questo cmdlet elenca i gruppi di nodi Amazon EKS associati al cluster specificato nel tuo Account AWS nella regione specificata.
Get-EKSNodegroupList -ClusterName PRODOutput:
ProdEKSNodeGroup-
Per i dettagli sull'API, consulta ListNodegroups nel AWS Strumenti per PowerShell Riferimento al cmdlet (V5).
-
L’esempio di codice seguente mostra come utilizzare Get-EKSResourceTag.
- Utensili per PowerShell V5
-
Esempio 1: questo cmdlet elenca i tag di una risorsa Amazon EKS.
Get-EKSResourceTag -ResourceArn "arn:aws:eks:us-west-2:012345678912:cluster/PROD"Output:
Key Value --- ----- Name EKSPRODCLUSTER-
Per i dettagli sull'API, vedi ListTagsForResource nel AWS Strumenti per PowerShell Riferimento al cmdlet (V5).
-
L’esempio di codice seguente mostra come utilizzare Get-EKSUpdate.
- Utensili per PowerShell V5
-
Esempio 1: questo cmdlet restituisce informazioni descrittive su un aggiornamento del cluster Amazon EKS o del gruppo di nodi gestiti associato.
Get-EKSUpdate -Name "PROD" -UpdateId "ee708232-7d2e-4ed7-9270-d0b5176f0726"Output:
CreatedAt : 12/25/2019 5:03:07 PM Errors : {} Id : ee708232-7d2e-4ed7-9270-d0b5176f0726 Params : {Amazon.EKS.Model.UpdateParam} Status : Successful Type : LoggingUpdate-
Per i dettagli sull'API, vedi DescribeUpdate nel AWS Strumenti per PowerShell Riferimento al cmdlet (V5).
-
L’esempio di codice seguente mostra come utilizzare Get-EKSUpdateList.
- Utensili per PowerShell V5
-
Esempio 1: questo cmdlet elenca gli aggiornamenti associati a un cluster Amazon EKS o a un gruppo di nodi gestiti nel tuo Account AWS, nella regione specificata.
Get-EKSUpdateList -Name "PROD"Output:
ee708232-7d2e-4ed7-9270-d0b5176f0726-
Per i dettagli sull'API, consulta ListUpdates nel AWS Strumenti per PowerShell Riferimento al cmdlet (V5).
-
L’esempio di codice seguente mostra come utilizzare New-EKSCluster.
- Utensili per PowerShell V5
-
Esempio 1: questo esempio crea un nuovo cluster denominato “prod’.
New-EKSCluster -Name prod -ResourcesVpcConfig @{SubnetIds=@("subnet-0a1b2c3d","subnet-3a2b1c0d");SecurityGroupIds="sg-6979fe18"} -RoleArn "arn:aws:iam::012345678901:role/eks-service-role"Output:
Arn : arn:aws:eks:us-west-2:012345678901:cluster/prod CertificateAuthority : Amazon.EKS.Model.Certificate ClientRequestToken : CreatedAt : 12/10/2018 9:25:31 PM Endpoint : Name : prod PlatformVersion : eks.3 ResourcesVpcConfig : Amazon.EKS.Model.VpcConfigResponse RoleArn : arn:aws:iam::012345678901:role/eks-service-role Status : CREATING Version : 1.10-
Per i dettagli sull'API, vedi CreateCluster nel AWS Strumenti per PowerShell Riferimento al cmdlet (V5).
-
L’esempio di codice seguente mostra come utilizzare New-EKSFargateProfile.
- Utensili per PowerShell V5
-
Esempio 1: questo cmdlet crea unProfilo AWS Fargate per il tuo cluster Amazon EKS. Devi disporre almeno di un profilo Fargate in un cluster per poter pianificare i pod nell’infrastruttura Fargate.
New-EKSFargateProfile -FargateProfileName EKSFargateProfile -ClusterName TEST -Subnet "subnet-02f6ff500ff2067a0", "subnet-0cd976f08d5fbfaae" -PodExecutionRoleArn arn:aws:iam::012345678912:role/AmazonEKSFargatePodExecutionRole -Selector @{Namespace="default"}Output:
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 : {}-
Per i dettagli sull'API, consulta CreateFargateProfile nel AWS Strumenti per PowerShell Riferimento al cmdlet (V5).
-
L’esempio di codice seguente mostra come utilizzare New-EKSNodeGroup.
- Utensili per PowerShell V5
-
Esempio 1: questo cmdlet crea un gruppo di nodi worker gestito per un cluster Amazon EKS. È possibile creare solo un gruppo di nodi per il cluster che sia uguale alla versione corrente di Kubernetes per il cluster. Tutti i gruppi di nodi vengono creati con l’ultima versione AMI per la rispettiva versione minore di Kubernetes del cluster.
New-EKSNodeGroup -NodeGroupName "ProdEKSNodeGroup" -AmiType "AL2_x86_64" -DiskSize 40 -ClusterName "PROD" -ScalingConfig_DesiredSize 2 -ScalingConfig_MinSize 2 -ScalingConfig_MaxSize 5 -InstanceType t3.large -NodeRole "arn:aws:iam::012345678912:role/NodeInstanceRole" -Subnet "subnet-0d1a9fff35efa7691","subnet-0a3f4928edbc224d4"Output:
AmiType : AL2_x86_64 ClusterName : PROD CreatedAt : 12/25/2019 10:16:45 AM DiskSize : 40 Health : Amazon.EKS.Model.NodegroupHealth InstanceTypes : {t3.large} Labels : {} ModifiedAt : 12/25/2019 10:16:45 AM NodegroupArn : arn:aws:eks:us-west-2:012345678912:nodegroup/PROD/ProdEKSNodeGroup/7eb79e47-82b6-04d9-e984-95110db6fa85 NodegroupName : ProdEKSNodeGroup NodeRole : arn:aws:iam::012345678912:role/NodeInstanceRole ReleaseVersion : 1.14.7-20190927 RemoteAccess : Resources : ScalingConfig : Amazon.EKS.Model.NodegroupScalingConfig Status : CREATING Subnets : {subnet-0d1a9fff35efa7691, subnet-0a3f4928edbc224d4} Tags : {} Version : 1.14-
Per i dettagli sull'API, vedi CreateNodegroup nel AWS Strumenti per PowerShell Riferimento al cmdlet (V5).
-
L’esempio di codice seguente mostra come utilizzare Remove-EKSCluster.
- Utensili per PowerShell V5
-
Esempio 1: questo cmdlet elimina il piano di controllo (control-plane) del cluster Amazon EKS.
Remove-EKSCluster -Name "DEV-KUBE-CL"Output:
Confirm Are you sure you want to perform this action? Performing the operation "Remove-EKSCluster (DeleteCluster)" on target "DEV-KUBE-CL". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): Y Arn : arn:aws:eks:us-west-2:012345678912:cluster/DEV-KUBE-CL CertificateAuthority : Amazon.EKS.Model.Certificate ClientRequestToken : CreatedAt : 12/25/2019 9:33:25 AM Endpoint : https://02E6D31E3E4F8C15D7BE7F58D527776A.yl4.us-west-2.eks.amazonaws.com Identity : Amazon.EKS.Model.Identity Logging : Amazon.EKS.Model.Logging Name : DEV-KUBE-CL PlatformVersion : eks.7 ResourcesVpcConfig : Amazon.EKS.Model.VpcConfigResponse RoleArn : arn:aws:iam::012345678912:role/eks-iam-role Status : DELETING Tags : {} Version : 1.14-
Per i dettagli sull'API, vedi DeleteCluster nel AWS Strumenti per PowerShell Riferimento al cmdlet (V5).
-
L’esempio di codice seguente mostra come utilizzare Remove-EKSFargateProfile.
- Utensili per PowerShell V5
-
Esempio 1: questo cmdlet elimina unProfilo AWS Fargate. Quando elimini un profilo Fargate, vengono eliminati anche tutti i pod in esecuzione in Fargate creati con tale profilo.
Remove-EKSFargateProfile -FargateProfileName "EKSFargate" -ClusterName "TEST"Output:
Confirm Are you sure you want to perform this action? Performing the operation "Remove-EKSFargateProfile (DeleteFargateProfile)" on target "EKSFargate". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): Y ClusterName : TEST CreatedAt : 12/26/2019 12:34:47 PM FargateProfileArn : arn:aws:eks:us-east-2:012345678912:fargateprofile/TEST/EKSFargate/42b7a119-e16b-a279-ce97-bdf303adec92 FargateProfileName : EKSFargate PodExecutionRoleArn : arn:aws:iam::012345678912:role/AmazonEKSFargatePodExecutionRole Selectors : {Amazon.EKS.Model.FargateProfileSelector} Status : DELETING Subnets : {subnet-0cd976f08d5fbfaae, subnet-02f6ff500ff2067a0} Tags : {}-
Per i dettagli sull'API, consulta DeleteFargateProfile nel AWS Strumenti per PowerShell Riferimento al cmdlet (V5).
-
L’esempio di codice seguente mostra come utilizzare Remove-EKSNodegroup.
- Utensili per PowerShell V5
-
Esempio 1: questo cmdlet elimina un gruppo di nodi Amazon EKS per un cluster.
Remove-EKSNodegroup -NodegroupName "ProdEKSNodeGroup" -ClusterName "PROD"Output:
Confirm Are you sure you want to perform this action? Performing the operation "Remove-EKSNodegroup (DeleteNodegroup)" on target "ProdEKSNodeGroup". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): Y AmiType : AL2_x86_64 ClusterName : PROD CreatedAt : 12/25/2019 10:16:45 AM DiskSize : 40 Health : Amazon.EKS.Model.NodegroupHealth InstanceTypes : {t3.large} Labels : {} ModifiedAt : 12/25/2019 11:01:16 AM NodegroupArn : arn:aws:eks:us-west-2:012345678912:nodegroup/PROD/ProdEKSNodeGroup/7eb79e47-82b6-04d9-e984-95110db6fa85 NodegroupName : ProdEKSNodeGroup NodeRole : arn:aws:iam::012345678912:role/NodeInstanceRole ReleaseVersion : 1.14.7-20190927 RemoteAccess : Resources : Amazon.EKS.Model.NodegroupResources ScalingConfig : Amazon.EKS.Model.NodegroupScalingConfig Status : DELETING Subnets : {subnet-0d1a9fff35efa7691, subnet-0a3f4928edbc224d4} Tags : {} Version : 1.14-
Per i dettagli sull'API, vedi DeleteNodegroup nel AWS Strumenti per PowerShell Riferimento al cmdlet (V5).
-
L’esempio di codice seguente mostra come utilizzare Remove-EKSResourceTag.
- Utensili per PowerShell V5
-
Esempio 1: questo cmdlet elimina i tag specificati da una risorsa EKS.
Remove-EKSResourceTag -ResourceArn "arn:aws:eks:us-west-2:012345678912:cluster/PROD" -TagKey "Name"Output:
Confirm Are you sure you want to perform this action? Performing the operation "Remove-EKSResourceTag (UntagResource)" on target "arn:aws:eks:us-west-2:012345678912:cluster/PROD". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): Y-
Per i dettagli sull'API, vedi UntagResource nel AWS Strumenti per PowerShell Riferimento al cmdlet (V5).
-
L’esempio di codice seguente mostra come utilizzare Update-EKSClusterConfig.
- Utensili per PowerShell V5
-
Esempio 1: aggiorna una configurazione di cluster Amazon EKS. Il cluster continua a funzionare durante l’aggiornamento.
Update-EKSClusterConfig -Name "PROD" -Logging_ClusterLogging @{Types="api","audit","authenticator","controllerManager","scheduler",Enabled="True"}Output:
CreatedAt : 12/25/2019 5:03:07 PM Errors : {} Id : ee708232-7d2e-4ed7-9270-d0b5176f0726 Params : {Amazon.EKS.Model.UpdateParam} Status : InProgress Type : LoggingUpdate-
Per i dettagli sull'API, vedi UpdateClusterConfig nel AWS Strumenti per PowerShell Riferimento al cmdlet (V5).
-
L’esempio di codice seguente mostra come utilizzare Update-EKSClusterVersion.
- Utensili per PowerShell V5
-
Esempio 1: questo cmdlet aggiorna un cluster Amazon EKS alla versione Kubernetes specificata. Il cluster continua a funzionare durante l’aggiornamento.
Update-EKSClusterVersion -Name "PROD-KUBE-CL" -Version 1.14Output:
CreatedAt : 12/26/2019 9:50:37 AM Errors : {} Id : ef186eff-3b3a-4c25-bcfc-3dcdf9e898a8 Params : {Amazon.EKS.Model.UpdateParam, Amazon.EKS.Model.UpdateParam} Status : InProgress Type : VersionUpdate-
Per i dettagli sull'API, vedi UpdateClusterVersion nel AWS Strumenti per PowerShell Riferimento al cmdlet (V5).
-