Halaman ini menjelaskan cara membuat inventaris cluster untuk fleet 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 subkumpulan informasi dalam fleet.
Fitur sinkronisasi ClusterProfile adalah sinkronisasi satu arah antara fleet dan inventaris cluster. Jika sinkronisasi ClusterProfile diaktifkan, fleet akan menjadi sumber kebenaran, dan setiap perubahan pada fleet akan otomatis diterapkan ke inventaris cluster oleh sinkronisasi ClusterProfile. Perubahan yang dilakukan langsung pada resource profil cluster tidak akan diterapkan ke fleet.
Sebelum memulai
Pastikan Anda telah mengikuti prasyarat umum untuk menggunakan fleet.
Buat fleet atau identifikasi fleet yang ada untuk digunakan.
Mengaktifkan 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 orkestrator 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 dalam fleet untuk digunakan sebagai cluster hub. Lihat bagian berikut untuk mengaktifkan sinkronisasi ClusterProfile di cluster yang ada.
Setelah Anda mengaktifkan fitur sinkronisasi ClusterProfile untuk fleet, fitur ini akan otomatis membuat profil cluster untuk setiap cluster dalam fleet menggunakan ClusterProfile API. Profil cluster ini otomatis dibuat, diperbarui, dan dihapus saat perubahan dilakukan pada fleet.
Mengaktifkan sinkronisasi ClusterProfile di cluster baru
Untuk membuat cluster untuk 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_clusterAnda. - 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_clusterAnda. - 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_clusterAnda. - 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_clusterAnda. - LOCATION: lokasi tempat cluster dibuat.
- NAMESPACE: namespace tempat profil cluster dibuat.
Jika tidak ditentukan, profil cluster akan dibuat di namespace
fleet-cluster-inventory.
Memverifikasi bahwa sinkronisasi ClusterProfile diaktifkan
Verifikasi bahwa sinkronisasi ClusterProfile diaktifkan dengan memverifikasi bahwa cluster hub menyertakan 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_clusterAnda. - LOCATION: lokasi tempat cluster dibuat.
Outputnya akan mirip dengan berikut ini:
resourceLabels:
fleet-clusterinventory-management-cluster: 'true'
Memverifikasi resource profil cluster yang dibuat
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_clusterAnda. - 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_clusterAnda. - 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_clusterAnda. - LOCATION: lokasi tempat cluster dibuat.
Langkah berikutnya
- Untuk mengetahui detail tentang cara mengintegrasikan sinkronisasi ClusterProfile dengan Argo CD, lihat Sinkronisasi ClusterProfile Argo CD.
- Orkestrator Multi-cluster menggunakan profil cluster. Hal ini membantu menjadwalkan deployment multi-cluster dan multi-region. Untuk mengetahui detailnya, lihat Ringkasan Orkestrator Multi-Cluster.