Ada lebih banyak contoh AWS SDK yang tersedia di repo Contoh SDK AWS Doc
Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
Amazon EKS contoh menggunakan Alat untuk PowerShell
Contoh kode berikut menunjukkan cara melakukan tindakan dan menerapkan skenario umum dengan menggunakan Alat AWS untuk PowerShell dengan Amazon EKS.
Tindakan adalah 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
-
Contoh 1: Cmdlet ini mengaitkan tag yang ditentukan ke sumber daya dengan ResourcEarn yang ditentukan.
Add-EKSResourceTag -ResourceArn "arn:aws:eks:us-west-2:012345678912:cluster/PROD" -Tag @{Name = "EKSPRODCLUSTER"}
-
Untuk detail API, lihat TagResourcedi Referensi Alat AWS untuk PowerShell Cmdlet.
-
Contoh kode berikut menunjukkan cara menggunakanGet-EKSCluster
.
- Alat untuk PowerShell
-
Contoh 1: Cmdlet ini menampilkan informasi deskriptif tentang kluster 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 DescribeClusterdi Referensi Alat AWS untuk PowerShell Cmdlet.
-
Contoh kode berikut menunjukkan cara menggunakanGet-EKSClusterList
.
- Alat untuk PowerShell
-
Contoh 1: Cmdlet ini mencantumkan kluster Amazon EKS di Region yang Akun AWS ditentukan.
Get-EKSClusterList
Output:
PROD
-
Untuk detail API, lihat ListClustersdi Referensi Alat AWS untuk PowerShell Cmdlet.
-
Contoh kode berikut menunjukkan cara menggunakanGet-EKSFargateProfile
.
- Alat untuk PowerShell
-
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 DescribeFargateProfiledi Referensi Alat AWS untuk PowerShell Cmdlet.
-
Contoh kode berikut menunjukkan cara menggunakanGet-EKSFargateProfileList
.
- Alat untuk PowerShell
-
Contoh 1: Cmdlet ini mencantumkan profil AWS Fargate yang terkait dengan cluster tertentu di Region yang ditentukan. Akun AWS
Get-EKSFargateProfileList -ClusterName "TEST"
Output:
EKSFargate EKSFargateProfile
-
Untuk detail API, lihat ListFargateProfilesdi Referensi Alat AWS untuk PowerShell Cmdlet.
-
Contoh kode berikut menunjukkan cara menggunakanGet-EKSNodegroup
.
- Alat untuk PowerShell
-
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 DescribeNodegroupdi Referensi Alat AWS untuk PowerShell Cmdlet.
-
Contoh kode berikut menunjukkan cara menggunakanGet-EKSNodegroupList
.
- Alat untuk PowerShell
-
Contoh 1: Cmdlet ini mencantumkan grup node Amazon EKS yang terkait dengan cluster yang ditentukan di Region yang ditentukan. Akun AWS
Get-EKSNodegroupList -ClusterName PROD
Output:
ProdEKSNodeGroup
-
Untuk detail API, lihat ListNodegroupsdi Referensi Alat AWS untuk PowerShell Cmdlet.
-
Contoh kode berikut menunjukkan cara menggunakanGet-EKSResourceTag
.
- Alat untuk PowerShell
-
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 ListTagsForResourcedi Referensi Alat AWS untuk PowerShell Cmdlet.
-
Contoh kode berikut menunjukkan cara menggunakanGet-EKSUpdate
.
- Alat untuk PowerShell
-
Contoh 1: Cmdlet ini menampilkan informasi deskriptif tentang pembaruan terhadap klaster Amazon EKS 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 DescribeUpdatedi Referensi Alat AWS untuk PowerShell Cmdlet.
-
Contoh kode berikut menunjukkan cara menggunakanGet-EKSUpdateList
.
- Alat untuk PowerShell
-
Contoh 1: Cmdlet ini mencantumkan pembaruan yang terkait dengan kluster Amazon EKS atau grup node terkelola di Akun AWS Wilayah yang ditentukan.
Get-EKSUpdateList -Name "PROD"
Output:
ee708232-7d2e-4ed7-9270-d0b5176f0726
-
Untuk detail API, lihat ListUpdatesdi Referensi Alat AWS untuk PowerShell Cmdlet.
-
Contoh kode berikut menunjukkan cara menggunakanNew-EKSCluster
.
- Alat untuk PowerShell
-
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 CreateClusterdi Referensi Alat AWS untuk PowerShell Cmdlet.
-
Contoh kode berikut menunjukkan cara menggunakanNew-EKSFargateProfile
.
- Alat untuk PowerShell
-
Contoh 1: Cmdlet ini membuat profil AWS Fargate untuk klaster Amazon EKS Anda. Anda harus memiliki setidaknya satu profil Fargate dalam sebuah 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 CreateFargateProfiledi Referensi Alat AWS untuk PowerShell Cmdlet.
-
Contoh kode berikut menunjukkan cara menggunakanNew-EKSNodeGroup
.
- Alat untuk PowerShell
-
Contoh 1: Cmdlet ini membuat grup node pekerja terkelola untuk klaster 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 minor Kubernetes 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 CreateNodegroupdi Referensi Alat AWS untuk PowerShell Cmdlet.
-
Contoh kode berikut menunjukkan cara menggunakanRemove-EKSCluster
.
- Alat untuk PowerShell
-
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 DeleteClusterdi Referensi Alat AWS untuk PowerShell Cmdlet.
-
Contoh kode berikut menunjukkan cara menggunakanRemove-EKSFargateProfile
.
- Alat untuk PowerShell
-
Contoh 1: Cmdlet ini menghapus profil AWS Fargate. 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 DeleteFargateProfiledi Referensi Alat AWS untuk PowerShell Cmdlet.
-
Contoh kode berikut menunjukkan cara menggunakanRemove-EKSNodegroup
.
- Alat untuk PowerShell
-
Contoh 1: Cmdlet ini menghapus grup node 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 DeleteNodegroupdi Referensi Alat AWS untuk PowerShell Cmdlet.
-
Contoh kode berikut menunjukkan cara menggunakanRemove-EKSResourceTag
.
- Alat untuk PowerShell
-
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 UntagResourcedi Referensi Alat AWS untuk PowerShell Cmdlet.
-
Contoh kode berikut menunjukkan cara menggunakanUpdate-EKSClusterConfig
.
- Alat untuk PowerShell
-
Contoh 1: Memperbarui konfigurasi klaster 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 UpdateClusterConfigdi Referensi Alat AWS untuk PowerShell Cmdlet.
-
Contoh kode berikut menunjukkan cara menggunakanUpdate-EKSClusterVersion
.
- Alat untuk PowerShell
-
Contoh 1: Cmdlet ini memperbarui kluster Amazon EKS ke versi Kubernetes yang ditentukan. Cluster Anda terus berfungsi selama pembaruan.
Update-EKSClusterVersion -Name "PROD-KUBE-CL" -Version 1.14
Output:
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 UpdateClusterVersiondi Referensi Alat AWS untuk PowerShell Cmdlet.
-