Deploy kluster khusus ACK berbasis Terway dengan VPC, vSwitch, dan add-on yang diprovisikan secara otomatis.
Jalankan kode ini di browser Anda di OpenAPI Portal.
Pembuatan kluster khusus ACK dibatasi. Untuk meminta akses, kirim tiket.
Prasyarat
Pastikan hal-hal berikut:
-
ACK telah diaktifkan (aktifkan ACK menggunakan Terraform).
-
Pasangan Kunci Akses (AccessKey pair) telah dibuat untuk RAM user yang menjalankan Terraform (Buat Pasangan Kunci Akses, RAM users).
Gunakan RAM user, bukan akun root Alibaba Cloud Anda. Izin terbatas mengurangi risiko jika kredensial dikompromikan.
-
Kebijakan izin minimum berikut telah dilampirkan ke RAM user. Mencakup pembuatan, penampilan, dan penghapusan Virtual Private Cloud (VPC), vSwitch, dan kluster ACK (berikan izin).
{ "Version": "1", "Statement": [ { "Effect": "Allow", "Action": [ "vpc:CreateVpc", "vpc:CreateVSwitch", "vpc:DescribeRouteTableList", "vpc:DescribeVpcAttribute", "vpc:ListEnhancedNatGatewayAvailableZones", "vpc:DescribeVSwitchAttributes", "vpc:DescribeNatGateways", "cs:CreateCluster", "cs:DescribeTaskInfo", "cs:DescribeClusterDetail", "cs:DescribeClusterCerts", "cs:CheckControlPlaneLogEnable", "vpc:DeleteVpc", "vpc:DeleteVSwitch", "cs:DeleteCluster" ], "Resource": "*" } ] } -
Terraform v0.12.28 atau versi lebih baru. Verifikasi dengan
terraform --version.Option
Best for
Terraform Explorer — online, tanpa perlu instalasi
Pengujian dan debugging cepat tanpa biaya
Cloud Shell — pra-instal, telah dikonfigurasi dengan kredensial Anda
Eksekusi cepat dan nyaman tanpa pengaturan lokal
Resource Orchestration Service (ROS) — Terraform terkelola
Template yang mendefinisikan resource Alibaba Cloud, AWS, atau Azure dengan siklus hidup terkelola
Lingkungan pengembangan kustom atau akses jaringan terbatas
-
alicloud_instance_types: menanyakan tipe instans Elastic Compute Service (ECS) yang memenuhi kondisi tertentu.
-
alicloud_vpc: membuat VPC.
-
alicloud_vswitch: membuat vSwitch (subnet) di dalam VPC.
-
alicloud_resource_manager_resource_groups: menanyakan kelompok sumber daya yang dikelola oleh RAM user.
-
alicloud_cs_kubernetes: membuat kluster khusus ACK.
Resource Terraform
Konfigurasi ini menggunakan resource berikut. Biaya berlaku—lepaskan resource tersebut bila tidak lagi diperlukan.
|
Resource |
Purpose |
|
Menanyakan tipe instans Elastic Compute Service (ECS) yang memenuhi kondisi tertentu |
|
|
Membuat VPC |
|
|
Membuat vSwitch (subnet) di dalam VPC |
|
|
|
Menanyakan kelompok sumber daya yang dikelola oleh RAM user |
|
|
Membuat kluster khusus ACK |
Konfigurasi ini memilih tipe instans yang tersedia di ketiga zona, memastikan node bidang kontrol dapat dijadwalkan di zona mana pun.
Hasilkan parameter Terraform dari konsol
Jika contoh tidak sesuai kebutuhan Anda, hasilkan parameter dari konsol ACK:
-
Login ke Konsol ACK. Di panel navigasi kiri, klik Clusters.
-
Di halaman Clusters, klik Cluster Templates.
-
Pilih tipe kluster, klik Create, lalu konfigurasikan kluster di halaman Cluster Configurations.
-
Di halaman Confirm, klik Console-to-Code.
-
Di sidebar, klik tab Terraform dan salin parameter yang dihasilkan.
Buat kluster khusus ACK dengan Terway
Langkah-langkah berikut membuat kluster khusus ACK dengan Terway. Konfigurasi ini menyediakan VPC, tiga vSwitch bidang kontrol, tiga vSwitch pod Terway, dan kluster—total 8 resource.
Langkah 1: Buat file konfigurasi
Langkah 2: Inisialisasi Terraform
terraform init
Inisialisasi yang berhasil mengembalikan:
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
Langkah 3: Pratinjau rencana eksekusi
terraform plan
Menampilkan pratinjau perubahan resource yang direncanakan tanpa menerapkannya.
Rencana yang berhasil mengembalikan:
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
...
Plan: 8 to add, 0 to change, 0 to destroy.
...
Langkah 4: Buat kluster
terraform apply
Saat diminta, ketik yes lalu tekan Enter.
Penerapan yang berhasil mengembalikan:
...
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
...
alicloud_cs_managed_kubernetes.default: Creation complete after 8m26s [id=************]
Apply complete! Resources: 8 added, 0 changed, 0 destroyed.
Verifikasi kluster
Setelah terraform apply selesai, verifikasi kluster menggunakan salah satu metode berikut:
Jalankan perintah terraform show
Opsi 1: Gunakan `terraform show`
terraform show
Menampilkan semua resource yang dibuat Terraform beserta status terkininya.
Login ke konsol ACK
Opsi 2: Periksa konsol ACK
Masuk ke Konsol ACK dan pastikan kluster baru muncul dalam daftar Clusters.
Bersihkan resource
Menjalankan terraform destroy akan menghapus permanen semua resource yang dibuat oleh konfigurasi ini. Tindakan ini tidak dapat dibatalkan.
Lepaskan resource tersebut. Lihat Perintah umum untuk opsi terraform destroy.
terraform destroy
Saat diminta, ketik yes lalu tekan Enter. Penghapusan yang berhasil mengembalikan:
...
Do you really want to destroy all resources?
Terraform will destroy all your managed infrastructure, as shown above.
There is no undo. Only 'yes' will be accepted to confirm.
Enter a value: yes
...
Destroy complete! Resources: 7 destroyed.
Kode contoh
Langkah selanjutnya
-
Gunakan Terraform untuk mengelola add-on — instal add-on untuk kluster Anda
-
Gunakan Terraform untuk membuat kelompok node dengan auto scaling yang diaktifkan — tambahkan kelompok node terkelola ke kluster
-
Buat tumpukan Terraform — deploy template Terraform dengan ROS