diff --git a/api/clusters/v1alpha1/cluster_types.go b/api/clusters/v1alpha1/cluster_types.go index cb36972..d932fca 100644 --- a/api/clusters/v1alpha1/cluster_types.go +++ b/api/clusters/v1alpha1/cluster_types.go @@ -90,11 +90,11 @@ const ( // +kubebuilder:selectablefield:JSONPath=".spec.profile" // +kubebuilder:printcolumn:JSONPath=".spec.purposes",name="Purposes",type=string // +kubebuilder:printcolumn:JSONPath=`.status.phase`,name="Phase",type=string -// +kubebuilder:printcolumn:JSONPath=`.metadata.annotations["clusters.openmcp.cloud/k8sversion"]`,name="Version",type=string -// +kubebuilder:printcolumn:JSONPath=`.metadata.annotations["clusters.openmcp.cloud/profile"]`,name="Profile",type=string -// +kubebuilder:printcolumn:JSONPath=`.metadata.labels["provider.clusters.openmcp.cloud"]`,name="Provider",type=string, priority=10 -// +kubebuilder:printcolumn:JSONPath=".spec.profile",name="ProfileRef",type=string,priority=10 +// +kubebuilder:printcolumn:JSONPath=`.metadata.labels["clusters.openmcp.cloud/k8sversion"]`,name="Version",type=string +// +kubebuilder:printcolumn:JSONPath=`.metadata.labels["clusters.openmcp.cloud/provider"]`,name="Provider",type=string +// +kubebuilder:printcolumn:JSONPath=".spec.profile",name="Profile",type=string,priority=10 // +kubebuilder:printcolumn:JSONPath=`.metadata.annotations["clusters.openmcp.cloud/providerinfo"]`,name="Info",type=string,priority=10 +// +kubebuilder:printcolumn:JSONPath=".status.apiServer",name="APIServer",type=string,priority=10 // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" // Cluster is the Schema for the clusters API diff --git a/api/clusters/v1alpha1/constants.go b/api/clusters/v1alpha1/constants.go index b58fe4e..0f8372e 100644 --- a/api/clusters/v1alpha1/constants.go +++ b/api/clusters/v1alpha1/constants.go @@ -56,24 +56,25 @@ const ( ) const ( - // K8sVersionAnnotation can be used to display the k8s version of the cluster. - K8sVersionAnnotation = GroupName + "/k8sversion" + // K8sVersionLabel can be used to display the k8s version of the cluster. + // This is useful since the cluster spec can contain only a partial version (e.g. "1.23") or no version at all, so the actual version can not be determined from the spec alone. + // The responsible ClusterProvider has to set this label. + K8sVersionLabel = GroupName + "/k8sversion" // ProviderInfoAnnotation can be used to display provider-specific information about the cluster. + // The responsible ClusterProvider can set this annotation to display additional information about the cluster. + // The value will be shown in a column when 'kubectl get clusters -o wide' is used. ProviderInfoAnnotation = GroupName + "/providerinfo" - // ProfileNameAnnotation can be used to display the actual name (not the hash) of the cluster profile. - ProfileNameAnnotation = GroupName + "/profile" - // EnvironmentAnnotation can be used to display the environment of the cluster. - EnvironmentAnnotation = GroupName + "/environment" - // ProviderAnnotation can be used to display the provider of the cluster. - ProviderAnnotation = GroupName + "/provider" + // ProviderLabel can be used to display the provider of the cluster. + // It is also used to indicate the provider that is responsible for an AccessRequest. + // For clusters, the responsible ClusterProvider has to set this label. + // For AccessRequests, the generic controller that is part of the openMCP Operator sets it. + ProviderLabel = GroupName + "/provider" // DeleteWithoutRequestsLabel marks that the corresponding cluster can be deleted if the scheduler removes the last request pointing to it. // Its value must be "true" for the label to take effect. DeleteWithoutRequestsLabel = GroupName + "/delete-without-requests" - // ProviderLabel is used to indicate the provider that is responsible for an AccessRequest. - ProviderLabel = "provider." + GroupName - // ProfileLabel is used to make the profile information easily accessible for the ClusterProviders. - ProfileLabel = "profile." + GroupName + // ProfileLabel is used to make the profile information easily accessible on AccessRequests. + ProfileLabel = GroupName + "/profile" ) const ( diff --git a/api/crds/manifests/clusters.openmcp.cloud_clusters.yaml b/api/crds/manifests/clusters.openmcp.cloud_clusters.yaml index c46157d..3b1c96e 100644 --- a/api/crds/manifests/clusters.openmcp.cloud_clusters.yaml +++ b/api/crds/manifests/clusters.openmcp.cloud_clusters.yaml @@ -23,24 +23,24 @@ spec: - jsonPath: .status.phase name: Phase type: string - - jsonPath: .metadata.annotations["clusters.openmcp.cloud/k8sversion"] + - jsonPath: .metadata.labels["clusters.openmcp.cloud/k8sversion"] name: Version type: string - - jsonPath: .metadata.annotations["clusters.openmcp.cloud/profile"] - name: Profile - type: string - - jsonPath: .metadata.labels["provider.clusters.openmcp.cloud"] + - jsonPath: .metadata.labels["clusters.openmcp.cloud/provider"] name: Provider - priority: 10 type: string - jsonPath: .spec.profile - name: ProfileRef + name: Profile priority: 10 type: string - jsonPath: .metadata.annotations["clusters.openmcp.cloud/providerinfo"] name: Info priority: 10 type: string + - jsonPath: .status.apiServer + name: APIServer + priority: 10 + type: string - jsonPath: .metadata.creationTimestamp name: Age type: date diff --git a/docs/controller/accessrequest.md b/docs/controller/accessrequest.md index a82de82..d220f85 100644 --- a/docs/controller/accessrequest.md +++ b/docs/controller/accessrequest.md @@ -8,8 +8,8 @@ To increase performance and simplify reconciliation logic in the individual Clus The added labels are: ```yaml -provider.clusters.openmcp.cloud: -profile.clusters.openmcp.cloud: +clusters.openmcp.cloud/provider: +clusters.openmcp.cloud/profile: ``` ClusterProviders should only reconcile `AccessRequest` resources where both labels are set and the value of the provider label matches their own provider name. Resources where either label is missing or the value of the provider label does not match the own provider name must be ignored. diff --git a/internal/controllers/accessrequest/testdata/test-04/accessrequest-profile.yaml b/internal/controllers/accessrequest/testdata/test-04/accessrequest-profile.yaml index b4d4a52..dcff739 100644 --- a/internal/controllers/accessrequest/testdata/test-04/accessrequest-profile.yaml +++ b/internal/controllers/accessrequest/testdata/test-04/accessrequest-profile.yaml @@ -4,7 +4,7 @@ metadata: name: mc-access-profile namespace: bar labels: - profile.clusters.openmcp.cloud: default + clusters.openmcp.cloud/profile: default spec: clusterRef: name: my-cluster diff --git a/internal/controllers/accessrequest/testdata/test-04/accessrequest-provider.yaml b/internal/controllers/accessrequest/testdata/test-04/accessrequest-provider.yaml index e216ad7..1ee0840 100644 --- a/internal/controllers/accessrequest/testdata/test-04/accessrequest-provider.yaml +++ b/internal/controllers/accessrequest/testdata/test-04/accessrequest-provider.yaml @@ -4,7 +4,7 @@ metadata: name: mc-access-provider namespace: bar labels: - provider.clusters.openmcp.cloud: asdf + clusters.openmcp.cloud/provider: asdf spec: clusterRef: name: my-cluster diff --git a/internal/controllers/accessrequest/testdata/test-05/accessrequest-profile.yaml b/internal/controllers/accessrequest/testdata/test-05/accessrequest-profile.yaml index 59d272f..7ff4664 100644 --- a/internal/controllers/accessrequest/testdata/test-05/accessrequest-profile.yaml +++ b/internal/controllers/accessrequest/testdata/test-05/accessrequest-profile.yaml @@ -4,7 +4,7 @@ metadata: name: mcr-access-profile namespace: bar labels: - profile.clusters.openmcp.cloud: wrong + clusters.openmcp.cloud/profile: wrong spec: requestRef: name: my-cluster diff --git a/internal/controllers/accessrequest/testdata/test-05/accessrequest-provider.yaml b/internal/controllers/accessrequest/testdata/test-05/accessrequest-provider.yaml index 91c6e99..e033baf 100644 --- a/internal/controllers/accessrequest/testdata/test-05/accessrequest-provider.yaml +++ b/internal/controllers/accessrequest/testdata/test-05/accessrequest-provider.yaml @@ -4,7 +4,7 @@ metadata: name: mcr-access-provider namespace: bar labels: - provider.clusters.openmcp.cloud: wrong + clusters.openmcp.cloud/provider: wrong spec: requestRef: name: my-cluster