This page describes how to generate a cluster inventory for an existing fleet. A cluster inventory for a fleet lets you work with open source and third party integrations that use the ClusterProfile specification.
A cluster inventory is the open-source equivalent of a fleet: a logical grouping of Kubernetes clusters and other resources that can be managed together. The ClusterProfile specification contains information that is a subset of the information in a fleet.
ClusterProfile sync feature is a one-way sync between a fleet and a cluster profile. When ClusterProfile sync is enabled, the fleet is the source of truth, and any changes to the fleet are automatically applied to the cluster inventory by ClusterProfile sync. Changes made directly to the cluster profile resources are not applied to the fleet.
Before you begin
Ensure that you have followed the general prerequisites for working with fleets.
Create a fleet or identify an existing fleet to work with.
Grant the required Identity and Access Management role (
roles/gkehub.editor
) to the user running the commands on this page. This role is needed to update the fleet membership.
Identify a hub cluster
ClusterProfile sync runs on one cluster within the fleet. This cluster is called a hub cluster.
Identify a cluster in the fleet to use as the hub cluster.
Enable ClusterProfile sync
After you the enable ClusterProfile sync feature for a fleet, it automatically creates a cluster profile using ClusterProfile. This cluster profile is automatically updated when changes are made to the fleet.
Enable ClusterProfile sync by labeling
the fleet membership of the hub cluster with
fleet-clusterinventory-management-cluster = true
. To do so, use
the following command:
gcloud container fleet memberships update MEMBERSHIP --location LOCATION
--update-labels=fleet-clusterinventory-management-cluster=true
Replace the following:
- MEMBERSHIP: the cluster membership name.
- LOCATION: the location where the hub cluster is registered.
By default, cluster profiles are created in the fleet-cluster-inventory
namespace. To change the namespace, specify the
fleet-clusterinventory-namespace
label.
gcloud container fleet memberships update MEMBERSHIP --location LOCATION
--update-labels=fleet-clusterinventory-namespace=NAMESPACE
Replace the following:
- MEMBERSHIP: the cluster membership name.
- LOCATION: the location where the cluster profiles are generated.
- NAMESPACE: the namespace where the cluster profiles are generated.
If not specified, the cluster profiles are generated in the
fleet-cluster-inventory
namespace.
Verify the ClusterProfile sync is enabled
Verify that ClusterProfile sync is enabled by verifying that the hub cluster
membership includes the fleet-clusterinventory-management-cluster = true
label. To do so, use the following command:
gcloud container fleet memberships describe MEMBERSHIP --location LOCATION
Replace the following::
- MEMBERSHIP: the cluster membership name.
- LOCATION: the location where the cluster is registered.
The output should be similar to the following:
labels:
fleet-clusterinventory-management-cluster: 'true'
Verify the generated cluster profile resources
Verify that the cluster profile resources are generated in the hub cluster by using the following command:
gcloud container fleet memberships get-credentials MEMBERSHIP --location LOCATION
kubectl get clusterprofiles -n fleet-cluster-inventory
Replace the following:
- MEMBERSHIP: the cluster membership name.
- LOCATION: the location where the cluster is registered.
The output should be similar to:
NAME AGE
cluster-1-us-west1 10s
cluster-2-us-west1 20s
This output should include a cluster profile for each cluster in the fleet.
The cluster profile name has the format
MEMBERSHIP_NAME-
LOCATION.
View the contents of the cluster profile
To view the contents of the cluster profile for a specific cluster, use the following command:
kubectl get clusterprofile <MEMBERSHIP_NAME> -n fleet-cluster-inventory -o yaml
Replace MEMBERSHIP with the cluster membership name.
The output should be similar to:
apiVersion: multicluster.x-k8s.io/v1alpha1
kind: ClusterProfile
metadata:
annotations:
fleet.gke.io/membershipName: projects/<var>PROJECT_NUMBER</var>/locations/<var>LOCATION</var>/memberships/<var>MEMBERSHIP_NAME</var>
labels:
x-k8s.io/cluster-manager: gke-fleet
name: <var>MEMBERSHIP_NAME</var>`-`<var>LOCATION</var>
namespace: fleet-cluster-inventory
Disable ClusterProfile Sync
Disable ClusterProfile Sync on the fleet's hub cluster by removing the
fleet-clusterinventory-management-cluster
fleet membership label:
gcloud container fleet memberships update MEMBERSHIP --location LOCATION
--remove-labels=fleet-clusterinventory-management-cluster \
Replace the following:
- MEMBERSHIP: the cluster membership name.
- LOCATION: the location where the cluster is registered.
What's next
- For details about integrating ClusterProfile syncer with Argo CD, see Argo CD ClusterProfile Syncer.
- Multi-cluster orchestrator uses cluster profiles. It helps schedule multi-cluster and multi-region deployments. For details, see Overview of Multi-Cluster Orchestrator