diff --git a/api/openapi-spec/swagger.json b/api/openapi-spec/swagger.json index e1420f56b..b63e41cc7 100644 --- a/api/openapi-spec/swagger.json +++ b/api/openapi-spec/swagger.json @@ -14139,6 +14139,10 @@ "description": "The API endpoint of the member cluster. This can be a hostname, hostname:port, IP or IP:port.", "type": "string" }, + "id": { + "description": "ID is the unique identifier for the cluster. It is different from the object uid(.metadata.uid) and typically collected automatically from member cluster during the progress of registration.\n\nThe value is collected in order: 1. If the registering cluster enabled ClusterProperty API and defined the cluster ID by\n creating a ClusterProperty object with name 'cluster.clusterset.k8s.io', Karmada would\n take the defined value in the ClusterProperty object.\n See https://github.com/kubernetes-sigs/about-api for more details about ClusterProperty API.\n2. Take the uid of 'kube-system' namespace on the registering cluster.\n\nPlease don't update this value unless you know what you are doing, because it will/may be used to : - uniquely identify the clusters within the Karmada system. - compose the DNS name of multi-cluster services.", + "type": "string" + }, "impersonatorSecretRef": { "description": "ImpersonatorSecretRef represents the secret contains the token of impersonator. The secret should hold credentials as follows: - secret.data.token", "$ref": "#/definitions/com.github.karmada-io.karmada.pkg.apis.cluster.v1alpha1.LocalSecretReference" diff --git a/pkg/apis/cluster/types.go b/pkg/apis/cluster/types.go index c1a15f0a9..38edcc98d 100644 --- a/pkg/apis/cluster/types.go +++ b/pkg/apis/cluster/types.go @@ -26,6 +26,26 @@ type Cluster struct { // ClusterSpec defines the desired state of a member cluster. type ClusterSpec struct { + // ID is the unique identifier for the cluster. + // It is different from the object uid(.metadata.uid) and typically collected automatically + // from member cluster during the progress of registration. + // + // The value is collected in order: + // 1. If the registering cluster enabled ClusterProperty API and defined the cluster ID by + // creating a ClusterProperty object with name 'cluster.clusterset.k8s.io', Karmada would + // take the defined value in the ClusterProperty object. + // See https://github.com/kubernetes-sigs/about-api for more details about ClusterProperty API. + // 2. Take the uid of 'kube-system' namespace on the registering cluster. + // + // Please don't update this value unless you know what you are doing, because + // it will/may be used to : + // - uniquely identify the clusters within the Karmada system. + // - compose the DNS name of multi-cluster services. + // + // +optional + // +kubebuilder:validation:Maxlength=128000 + ID string `json:"id,omitempty"` + // SyncMode describes how a cluster sync resources from karmada control plane. // +required SyncMode ClusterSyncMode diff --git a/pkg/apis/cluster/v1alpha1/types.go b/pkg/apis/cluster/v1alpha1/types.go index 60403f363..11bdced40 100644 --- a/pkg/apis/cluster/v1alpha1/types.go +++ b/pkg/apis/cluster/v1alpha1/types.go @@ -37,6 +37,26 @@ type Cluster struct { // ClusterSpec defines the desired state of a member cluster. type ClusterSpec struct { + // ID is the unique identifier for the cluster. + // It is different from the object uid(.metadata.uid) and typically collected automatically + // from member cluster during the progress of registration. + // + // The value is collected in order: + // 1. If the registering cluster enabled ClusterProperty API and defined the cluster ID by + // creating a ClusterProperty object with name 'cluster.clusterset.k8s.io', Karmada would + // take the defined value in the ClusterProperty object. + // See https://github.com/kubernetes-sigs/about-api for more details about ClusterProperty API. + // 2. Take the uid of 'kube-system' namespace on the registering cluster. + // + // Please don't update this value unless you know what you are doing, because + // it will/may be used to : + // - uniquely identify the clusters within the Karmada system. + // - compose the DNS name of multi-cluster services. + // + // +optional + // +kubebuilder:validation:Maxlength=128000 + ID string `json:"id,omitempty"` + // SyncMode describes how a cluster sync resources from karmada control plane. // +kubebuilder:validation:Enum=Push;Pull // +required diff --git a/pkg/apis/cluster/v1alpha1/zz_generated.conversion.go b/pkg/apis/cluster/v1alpha1/zz_generated.conversion.go index 4509418fa..86cd65413 100644 --- a/pkg/apis/cluster/v1alpha1/zz_generated.conversion.go +++ b/pkg/apis/cluster/v1alpha1/zz_generated.conversion.go @@ -268,6 +268,7 @@ func Convert_url_Values_To_v1alpha1_ClusterProxyOptions(in *url.Values, out *Clu } func autoConvert_v1alpha1_ClusterSpec_To_cluster_ClusterSpec(in *ClusterSpec, out *cluster.ClusterSpec, s conversion.Scope) error { + out.ID = in.ID out.SyncMode = cluster.ClusterSyncMode(in.SyncMode) out.APIEndpoint = in.APIEndpoint out.SecretRef = (*cluster.LocalSecretReference)(unsafe.Pointer(in.SecretRef)) @@ -288,6 +289,7 @@ func Convert_v1alpha1_ClusterSpec_To_cluster_ClusterSpec(in *ClusterSpec, out *c } func autoConvert_cluster_ClusterSpec_To_v1alpha1_ClusterSpec(in *cluster.ClusterSpec, out *ClusterSpec, s conversion.Scope) error { + out.ID = in.ID out.SyncMode = ClusterSyncMode(in.SyncMode) out.APIEndpoint = in.APIEndpoint out.SecretRef = (*LocalSecretReference)(unsafe.Pointer(in.SecretRef)) diff --git a/pkg/generated/openapi/zz_generated.openapi.go b/pkg/generated/openapi/zz_generated.openapi.go index 3cc42bc8f..35fa44135 100644 --- a/pkg/generated/openapi/zz_generated.openapi.go +++ b/pkg/generated/openapi/zz_generated.openapi.go @@ -642,6 +642,13 @@ func schema_pkg_apis_cluster_v1alpha1_ClusterSpec(ref common.ReferenceCallback) Description: "ClusterSpec defines the desired state of a member cluster.", Type: []string{"object"}, Properties: map[string]spec.Schema{ + "id": { + SchemaProps: spec.SchemaProps{ + Description: "ID is the unique identifier for the cluster. It is different from the object uid(.metadata.uid) and typically collected automatically from member cluster during the progress of registration.\n\nThe value is collected in order: 1. If the registering cluster enabled ClusterProperty API and defined the cluster ID by\n creating a ClusterProperty object with name 'cluster.clusterset.k8s.io', Karmada would\n take the defined value in the ClusterProperty object.\n See https://github.com/kubernetes-sigs/about-api for more details about ClusterProperty API.\n2. Take the uid of 'kube-system' namespace on the registering cluster.\n\nPlease don't update this value unless you know what you are doing, because it will/may be used to : - uniquely identify the clusters within the Karmada system. - compose the DNS name of multi-cluster services.", + Type: []string{"string"}, + Format: "", + }, + }, "syncMode": { SchemaProps: spec.SchemaProps{ Description: "SyncMode describes how a cluster sync resources from karmada control plane.",