Halaman ini menjelaskan cara membuat inventaris cluster untuk armada yang ada. Inventaris cluster untuk fleet memungkinkan Anda menggunakan integrasi open source dan pihak ketiga yang menggunakan spesifikasi ClusterProfile.
Inventaris cluster adalah padanan open source dari fleet: pengelompokan logis cluster Kubernetes dan resource lain yang dapat dikelola bersama. Spesifikasi ClusterProfile berisi informasi yang merupakan subset dari informasi dalam fleet.
Fitur sinkronisasi ClusterProfile adalah sinkronisasi satu arah antara inventaris cluster dan armada. Jika sinkronisasi ClusterProfile diaktifkan, armada adalah sumber tepercaya, dan setiap perubahan pada armada akan otomatis diterapkan ke inventaris cluster oleh sinkronisasi ClusterProfile. Perubahan yang dilakukan langsung pada resource profil cluster tidak diterapkan ke armada.
Sebelum memulai
Pastikan Anda telah mengikuti prasyarat umum untuk menggunakan armada.
Buat armada atau identifikasi armada yang ada untuk digunakan.
Aktifkan sinkronisasi ClusterProfile
Sinkronisasi ClusterProfile berjalan terhadap satu cluster dalam fleet. Cluster ini disebut cluster hub dan dapat digunakan untuk menjalankan pengontrol multi-cluster yang memerlukan informasi tentang cluster lainnya dalam fleet. Contoh pengontrol multi-cluster mencakup pengontrol Argo CD, dan pengelola multi-cluster. Sebaiknya Anda tidak menjalankan workload lain di cluster hub.
Aktifkan sinkronisasi ClusterProfile di cluster dengan menambahkan label
fleet-clusterinventory-management-cluster=true
. Anda dapat melakukan hal berikut:
- Buat cluster baru untuk digunakan sebagai cluster hub. Lihat bagian berikut untuk mengaktifkan sinkronisasi ClusterProfile di cluster baru.
- Identifikasi cluster di fleet yang akan digunakan sebagai cluster hub. Lihat bagian berikut untuk mengaktifkan sinkronisasi ClusterProfile pada cluster yang sudah ada.
Setelah Anda mengaktifkan fitur sinkronisasi ClusterProfile untuk fleet, fitur ini akan otomatis membuat profil cluster untuk setiap cluster dalam fleet menggunakan API ClusterProfile. Profil cluster ini dibuat, diperbarui, dan dihapus secara otomatis saat perubahan dilakukan pada fleet.
Mengaktifkan sinkronisasi ClusterProfile di cluster baru
Untuk membuat cluster bagi cluster hub, dan mengaktifkan sinkronisasi ClusterProfile, gunakan perintah berikut:
gcloud container clusters create CLUSTER --location LOCATION --enable-fleet
--labels=fleet-clusterinventory-management-cluster=true
Ganti kode berikut:
- CLUSTER: nama resource
google_container_cluster
Anda. - LOCATION: lokasi tempat cluster dibuat.
Secara default, profil cluster dibuat di namespace fleet-cluster-inventory
. Untuk mengubah namespace, tentukan label
fleet-clusterinventory-namespace
.
gcloud container clusters update CLUSTER --location LOCATION
--update-labels=fleet-clusterinventory-namespace=NAMESPACE
Ganti kode berikut:
- CLUSTER: nama resource
google_container_cluster
Anda. - LOCATION: lokasi tempat cluster dibuat.
- NAMESPACE: namespace tempat profil cluster dibuat.
Jika tidak ditentukan, profil cluster akan dibuat di namespace
fleet-cluster-inventory
.
Mengaktifkan sinkronisasi ClusterProfile di cluster yang ada
Untuk mengaktifkan sinkronisasi ClusterProfile di cluster yang ada, gunakan perintah berikut:
gcloud container clusters update CLUSTER --location LOCATION
--update-labels=fleet-clusterinventory-management-cluster=true
Ganti kode berikut:
- CLUSTER: nama resource
google_container_cluster
Anda. - LOCATION: lokasi tempat cluster dibuat.
Secara default, profil cluster dibuat di namespace fleet-cluster-inventory
. Untuk mengubah namespace, tentukan label
fleet-clusterinventory-namespace
.
gcloud container clusters update CLUSTER --location LOCATION
--update-labels=fleet-clusterinventory-namespace=NAMESPACE
Ganti kode berikut:
- CLUSTER: nama resource
google_container_cluster
Anda. - LOCATION: lokasi tempat cluster dibuat.
- NAMESPACE: namespace tempat profil cluster dibuat.
Jika tidak ditentukan, profil cluster akan dibuat di namespace
fleet-cluster-inventory
.
Memastikan sinkronisasi ClusterProfile diaktifkan
Pastikan sinkronisasi ClusterProfile diaktifkan dengan memverifikasi bahwa cluster hub
mencakup label fleet-clusterinventory-management-cluster = true
. Untuk melakukannya, gunakan perintah berikut:
gcloud container clusters describe CLUSTER --location LOCATION
Ganti kode berikut:
- CLUSTER: nama resource
google_container_cluster
Anda. - LOCATION: lokasi tempat cluster dibuat.
Outputnya akan mirip dengan berikut ini:
resourceLabels:
fleet-clusterinventory-management-cluster: 'true'
Memverifikasi resource profil cluster yang dihasilkan
Verifikasi bahwa resource profil cluster dibuat di cluster hub menggunakan perintah berikut:
gcloud container clusters get-credentials CLUSTER --location LOCATION
kubectl get clusterprofiles -n fleet-cluster-inventory
Ganti kode berikut:
- CLUSTER: nama resource
google_container_cluster
Anda. - LOCATION: lokasi tempat cluster dibuat.
Output-nya akan terlihat seperti ini:
NAME AGE
cluster-1-us-west1 10s
cluster-2-us-west1 20s
Output ini harus menyertakan profil cluster untuk setiap cluster dalam fleet.
Nama profil cluster memiliki format
MEMBERSHIP-
LOCATION.
Melihat konten profil cluster
Untuk melihat konten profil cluster untuk cluster tertentu, gunakan perintah berikut:
kubectl get clusterprofile CLUSTER-LOCATION -n fleet-cluster-inventory -o yaml
Ganti kode berikut:
- CLUSTER: nama resource
google_container_cluster
Anda. - LOCATION: lokasi tempat cluster dibuat.
Output-nya akan terlihat seperti ini:
apiVersion: multicluster.x-k8s.io/v1alpha1
kind: ClusterProfile
metadata:
annotations:
fleet.gke.io/membershipName: projects/123456789/locations/us-west1/memberships/cluster-1
labels:
x-k8s.io/cluster-manager: gke-fleet
name: cluster-1-us-west1
namespace: fleet-cluster-inventory
Menonaktifkan Sinkronisasi ClusterProfile
Nonaktifkan sinkronisasi ClusterProfile di cluster hub fleet dengan menghapus label
fleet-clusterinventory-management-cluster
:
gcloud container clusters update CLUSTER --location LOCATION \
--remove-labels=fleet-clusterinventory-management-cluster
Ganti kode berikut:
- CLUSTER: nama resource
google_container_cluster
Anda. - LOCATION: lokasi tempat cluster dibuat.
Langkah berikutnya
- Untuk mengetahui detail tentang mengintegrasikan sinkronisasi ClusterProfile dengan Argo CD, lihat Penyinkron ClusterProfile Argo CD.
- Multi-cluster Orchestrator menggunakan profil cluster. Fitur ini membantu menjadwalkan deployment multi-cluster dan multi-region. Untuk mengetahui detailnya, lihat Ringkasan Multi-Cluster Orchestrator.