Versi 5 (V5) Alat AWS untuk PowerShell telah dirilis!
Untuk informasi tentang mengubah perubahan dan memigrasikan aplikasi Anda, lihat topik https://docs.aws.amazon.com/powershell/v5/userguide/migrating-v5.html migrasi.
Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
Contoh Amazon EKS menggunakan Alat untuk PowerShell V5
Contoh kode berikut menunjukkan cara melakukan tindakan dan menerapkan skenario umum dengan menggunakan Alat AWS untuk PowerShell V5 dengan Amazon EKS.
Tindakan merupakan kutipan kode dari program yang lebih besar dan harus dijalankan dalam konteks. Sementara tindakan menunjukkan cara memanggil fungsi layanan individual, Anda dapat melihat tindakan dalam konteks dalam skenario terkait.
Setiap contoh menyertakan tautan ke kode sumber lengkap, di mana Anda dapat menemukan instruksi tentang cara mengatur dan menjalankan kode dalam konteks.
Topik
Tindakan
Contoh kode berikut menunjukkan cara menggunakanAdd-EKSResourceTag.
- Alat untuk PowerShell V5
-
Contoh 1: Cmdlet ini mengaitkan tag yang ditentukan ke sumber daya dengan ResourceLearn yang ditentukan.
Add-EKSResourceTag -ResourceArn "arn:aws:eks:us-west-2:012345678912:cluster/PROD" -Tag @{Name = "EKSPRODCLUSTER"}-
Untuk detail API, lihat TagResource di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EKSCluster.
- Alat untuk PowerShell V5
-
Contoh 1: Cmdlet ini mengembalikan informasi deskriptif tentang 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-
Untuk detail API, lihat DescribeCluster di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EKSClusterList.
- Alat untuk PowerShell V5
-
Contoh 1: Cmdlet ini mencantumkan cluster Amazon EKS di Wilayah Akun AWS yang ditentukan.
Get-EKSClusterListOutput:
PROD-
Untuk detail API, lihat ListClusters di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EKSFargateProfile.
- Alat untuk PowerShell V5
-
Contoh 1: Cmdlet ini mengembalikan informasi deskriptif tentang profil AWS 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 : {}-
Untuk detail API, lihat DescribeFargateProfile di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EKSFargateProfileList.
- Alat untuk PowerShell V5
-
Contoh 1: Cmdlet ini mencantumkan profil AWS Fargate yang terkait dengan cluster yang ditentukan di Wilayah yang Akun AWS ditentukan.
Get-EKSFargateProfileList -ClusterName "TEST"Output:
EKSFargate EKSFargateProfile-
Untuk detail API, lihat ListFargateProfiles di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EKSNodegroup.
- Alat untuk PowerShell V5
-
Contoh 1: Cmdlet ini mengembalikan informasi deskriptif tentang grup node 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-
Untuk detail API, lihat DescribeNodegroup di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EKSNodegroupList.
- Alat untuk PowerShell V5
-
Contoh 1: Cmdlet ini mencantumkan grup simpul Amazon EKS yang terkait dengan cluster yang ditentukan Akun AWS di Wilayah yang ditentukan.
Get-EKSNodegroupList -ClusterName PRODOutput:
ProdEKSNodeGroup-
Untuk detail API, lihat ListNodegroups di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EKSResourceTag.
- Alat untuk PowerShell V5
-
Contoh 1: Cmdlet ini mencantumkan tag untuk sumber daya Amazon EKS.
Get-EKSResourceTag -ResourceArn "arn:aws:eks:us-west-2:012345678912:cluster/PROD"Output:
Key Value --- ----- Name EKSPRODCLUSTER-
Untuk detail API, lihat ListTagsForResource di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EKSUpdate.
- Alat untuk PowerShell V5
-
Contoh 1: Cmdlet ini mengembalikan informasi deskriptif tentang pembaruan terhadap cluster Amazon EKS Anda atau grup node terkelola terkait.
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-
Untuk detail API, lihat DescribeUpdate di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EKSUpdateList.
- Alat untuk PowerShell V5
-
Contoh 1: Cmdlet ini mencantumkan pembaruan yang terkait dengan cluster Amazon EKS atau grup node terkelola di Anda Akun AWS, di Wilayah yang ditentukan.
Get-EKSUpdateList -Name "PROD"Output:
ee708232-7d2e-4ed7-9270-d0b5176f0726-
Untuk detail API, lihat ListUpdates di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-EKSCluster.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini membuat cluster baru yang disebut '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-
Untuk detail API, lihat CreateCluster di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-EKSFargateProfile.
- Alat untuk PowerShell V5
-
Contoh 1: Cmdlet ini membuat profil AWS Fargate untuk cluster Amazon EKS Anda. Anda harus memiliki setidaknya satu profil Fargate dalam cluster untuk dapat menjadwalkan pod pada infrastruktur 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 : {}-
Untuk detail API, lihat CreateFargateProfile di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-EKSNodeGroup.
- Alat untuk PowerShell V5
-
Contoh 1: Cmdlet ini membuat grup node pekerja terkelola untuk cluster Amazon EKS. Anda hanya dapat membuat grup node untuk klaster Anda yang sama dengan versi Kubernetes terkini untuk klaster tersebut. Semua grup node dibuat dengan versi rilis AMI terbaru untuk masing-masing versi Kubernetes minor dari 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-
Untuk detail API, lihat CreateNodegroup di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRemove-EKSCluster.
- Alat untuk PowerShell V5
-
Contoh 1: Cmdlet ini menghapus bidang kontrol 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-
Untuk detail API, lihat DeleteCluster di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRemove-EKSFargateProfile.
- Alat untuk PowerShell V5
-
Contoh 1: Cmdlet ini menghapus profil Fargate. AWS Saat Anda menghapus profil Fargate, semua pod yang berjalan di Fargate yang dibuat dengan profil akan dihapus.
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 : {}-
Untuk detail API, lihat DeleteFargateProfile di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRemove-EKSNodegroup.
- Alat untuk PowerShell V5
-
Contoh 1: Cmdlet ini menghapus grup simpul Amazon EKS untuk sebuah 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-
Untuk detail API, lihat DeleteNodegroup di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRemove-EKSResourceTag.
- Alat untuk PowerShell V5
-
Contoh 1: Cmdlet ini menghapus tag tertentu dari sumber daya 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-
Untuk detail API, lihat UntagResource di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanUpdate-EKSClusterConfig.
- Alat untuk PowerShell V5
-
Contoh 1: Memperbarui konfigurasi cluster Amazon EKS. Cluster Anda terus berfungsi selama pembaruan.
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-
Untuk detail API, lihat UpdateClusterConfig di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanUpdate-EKSClusterVersion.
- Alat untuk PowerShell V5
-
Contoh 1: Cmdlet ini memperbarui cluster Amazon EKS ke versi Kubernetes yang ditentukan. Cluster Anda terus berfungsi selama pembaruan.
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-
Untuk detail API, lihat UpdateClusterVersion di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-