Skip to content

Commit 7bc4b22

Browse files
committed
cleanup labels
1 parent e73e54f commit 7bc4b22

File tree

8 files changed

+30
-29
lines changed

8 files changed

+30
-29
lines changed

api/clusters/v1alpha1/cluster_types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ const (
9090
// +kubebuilder:selectablefield:JSONPath=".spec.profile"
9191
// +kubebuilder:printcolumn:JSONPath=".spec.purposes",name="Purposes",type=string
9292
// +kubebuilder:printcolumn:JSONPath=`.status.phase`,name="Phase",type=string
93-
// +kubebuilder:printcolumn:JSONPath=`.metadata.annotations["clusters.openmcp.cloud/k8sversion"]`,name="Version",type=string
94-
// +kubebuilder:printcolumn:JSONPath=`.metadata.annotations["clusters.openmcp.cloud/profile"]`,name="Profile",type=string
95-
// +kubebuilder:printcolumn:JSONPath=`.metadata.labels["provider.clusters.openmcp.cloud"]`,name="Provider",type=string, priority=10
96-
// +kubebuilder:printcolumn:JSONPath=".spec.profile",name="ProfileRef",type=string,priority=10
93+
// +kubebuilder:printcolumn:JSONPath=`.metadata.labels["clusters.openmcp.cloud/k8sversion"]`,name="Version",type=string
94+
// +kubebuilder:printcolumn:JSONPath=`.metadata.labels["clusters.openmcp.cloud/provider"]`,name="Provider",type=string
95+
// +kubebuilder:printcolumn:JSONPath=".spec.profile",name="Profile",type=string,priority=10
9796
// +kubebuilder:printcolumn:JSONPath=`.metadata.annotations["clusters.openmcp.cloud/providerinfo"]`,name="Info",type=string,priority=10
97+
// +kubebuilder:printcolumn:JSONPath=".status.apiServer",name="APIServer",type=string,priority=10
9898
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
9999

100100
// Cluster is the Schema for the clusters API

api/clusters/v1alpha1/constants.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,25 @@ const (
5656
)
5757

5858
const (
59-
// K8sVersionAnnotation can be used to display the k8s version of the cluster.
60-
K8sVersionAnnotation = GroupName + "/k8sversion"
59+
// K8sVersionLabel can be used to display the k8s version of the cluster.
60+
// 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.
61+
// The responsible ClusterProvider has to set this label.
62+
K8sVersionLabel = GroupName + "/k8sversion"
6163
// ProviderInfoAnnotation can be used to display provider-specific information about the cluster.
64+
// The responsible ClusterProvider can set this annotation to display additional information about the cluster.
65+
// The value will be shown in a column when 'kubectl get clusters -o wide' is used.
6266
ProviderInfoAnnotation = GroupName + "/providerinfo"
63-
// ProfileNameAnnotation can be used to display the actual name (not the hash) of the cluster profile.
64-
ProfileNameAnnotation = GroupName + "/profile"
65-
// EnvironmentAnnotation can be used to display the environment of the cluster.
66-
EnvironmentAnnotation = GroupName + "/environment"
67-
// ProviderAnnotation can be used to display the provider of the cluster.
68-
ProviderAnnotation = GroupName + "/provider"
67+
// ProviderLabel can be used to display the provider of the cluster.
68+
// It is also used to indicate the provider that is responsible for an AccessRequest.
69+
// For clusters, the responsible ClusterProvider has to set this label.
70+
// For AccessRequests, the generic controller that is part of the openMCP Operator sets it.
71+
ProviderLabel = GroupName + "/provider"
6972

7073
// DeleteWithoutRequestsLabel marks that the corresponding cluster can be deleted if the scheduler removes the last request pointing to it.
7174
// Its value must be "true" for the label to take effect.
7275
DeleteWithoutRequestsLabel = GroupName + "/delete-without-requests"
73-
// ProviderLabel is used to indicate the provider that is responsible for an AccessRequest.
74-
ProviderLabel = "provider." + GroupName
75-
// ProfileLabel is used to make the profile information easily accessible for the ClusterProviders.
76-
ProfileLabel = "profile." + GroupName
76+
// ProfileLabel is used to make the profile information easily accessible on AccessRequests.
77+
ProfileLabel = GroupName + "/profile"
7778
)
7879

7980
const (

api/crds/manifests/clusters.openmcp.cloud_clusters.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,24 @@ spec:
2323
- jsonPath: .status.phase
2424
name: Phase
2525
type: string
26-
- jsonPath: .metadata.annotations["clusters.openmcp.cloud/k8sversion"]
26+
- jsonPath: .metadata.labels["clusters.openmcp.cloud/k8sversion"]
2727
name: Version
2828
type: string
29-
- jsonPath: .metadata.annotations["clusters.openmcp.cloud/profile"]
30-
name: Profile
31-
type: string
32-
- jsonPath: .metadata.labels["provider.clusters.openmcp.cloud"]
29+
- jsonPath: .metadata.labels["clusters.openmcp.cloud/provider"]
3330
name: Provider
34-
priority: 10
3531
type: string
3632
- jsonPath: .spec.profile
37-
name: ProfileRef
33+
name: Profile
3834
priority: 10
3935
type: string
4036
- jsonPath: .metadata.annotations["clusters.openmcp.cloud/providerinfo"]
4137
name: Info
4238
priority: 10
4339
type: string
40+
- jsonPath: .status.apiServer
41+
name: APIServer
42+
priority: 10
43+
type: string
4444
- jsonPath: .metadata.creationTimestamp
4545
name: Age
4646
type: date

docs/controller/accessrequest.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ To increase performance and simplify reconciliation logic in the individual Clus
88

99
The added labels are:
1010
```yaml
11-
provider.clusters.openmcp.cloud: <provider-name>
12-
profile.clusters.openmcp.cloud: <profile-name>
11+
clusters.openmcp.cloud/provider: <provider-name>
12+
clusters.openmcp.cloud/profile: <profile-name>
1313
```
1414
1515
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.

internal/controllers/accessrequest/testdata/test-04/accessrequest-profile.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ metadata:
44
name: mc-access-profile
55
namespace: bar
66
labels:
7-
profile.clusters.openmcp.cloud: default
7+
clusters.openmcp.cloud/profile: default
88
spec:
99
clusterRef:
1010
name: my-cluster

internal/controllers/accessrequest/testdata/test-04/accessrequest-provider.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ metadata:
44
name: mc-access-provider
55
namespace: bar
66
labels:
7-
provider.clusters.openmcp.cloud: asdf
7+
clusters.openmcp.cloud/provider: asdf
88
spec:
99
clusterRef:
1010
name: my-cluster

internal/controllers/accessrequest/testdata/test-05/accessrequest-profile.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ metadata:
44
name: mcr-access-profile
55
namespace: bar
66
labels:
7-
profile.clusters.openmcp.cloud: wrong
7+
clusters.openmcp.cloud/profile: wrong
88
spec:
99
requestRef:
1010
name: my-cluster

internal/controllers/accessrequest/testdata/test-05/accessrequest-provider.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ metadata:
44
name: mcr-access-provider
55
namespace: bar
66
labels:
7-
provider.clusters.openmcp.cloud: wrong
7+
clusters.openmcp.cloud/provider: wrong
88
spec:
99
requestRef:
1010
name: my-cluster

0 commit comments

Comments
 (0)