Skip to content

Commit d68971b

Browse files
committed
proposal change for clusterset api
Signed-off-by: ldpliu <[email protected]>
1 parent 8fa2df8 commit d68971b

File tree

2 files changed

+59
-35
lines changed

2 files changed

+59
-35
lines changed

enhancements/sig-architecture/30-clusterset-override/README.md

Lines changed: 58 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ So, In this proposal, we change the managedClusterSets spec and want to provide
3030

3131
```go
3232
type ManagedClusterSetSpec struct {
33-
// Selector represents a selector of ManagedClusters by labels and names.
33+
// Selector represents a selector of ManagedClusters.
3434
ClusterSelector ManagedClusterSelector `json:"clusterSelector"`
3535
}
3636

@@ -324,72 +324,96 @@ Currently, managedClusterSet has three consumers: [placement](https://github.com
324324

325325
So we could finish the migration by four steps, and step 1 and step 2 will be finished in OCM 0.7.0. and step 3 and step 4 will be finished in OCM 0.8.0
326326

327-
1. [Implement in OCM 0.7.0]Update the managedClusterSet API which only includes an exclusive way to select target managedClusters.
327+
1. [Implement in OCM 0.7.0]Update the managedClusterSet API which only includes "LegacyClusterSetLabel" in clusterSelector.
328328

329329
```go
330+
// ManagedClusterSetSpec describes the attributes of the ManagedClusterSet
330331
type ManagedClusterSetSpec struct {
331-
// Selector represents a selector of ManagedClusters by labels and names.
332+
// ClusterSelector represents a selector of ManagedClusters
333+
// +optional
334+
// +kubebuilder:default:={selectorType: LegacyClusterSetLabel}
335+
ClusterSelector ManagedClusterSelector `json:"clusterSelector,omitempty"`
336+
}
337+
338+
// ManagedClusterSelector represents a selector of ManagedClusters
339+
type ManagedClusterSelector struct {
340+
// SelectorType could only be "LegacyClusterSetLabel" now, will support more SelectorType later
341+
// "LegacyClusterSetLabel" means to use label "cluster.open-cluster-management.io/clusterset:<ManagedClusterSet Name>"" to select target clusters.
342+
// +kubebuilder:validation:Enum=LegacyClusterSetLabel
343+
// +kubebuilder:default:=LegacyClusterSetLabel
344+
// +required
345+
SelectorType SelectorType `json:"selectorType,omitempty"`
346+
}
347+
348+
type SelectorType string
349+
350+
const (
351+
LegacyClusterSetLabel SelectorType = "LegacyClusterSetLabel"
352+
)
353+
```
354+
355+
2. [Implement in OCM 0.7.0]`multicloud-operators-foundation`, `submariner-addon`, `placement` change the code to integrate with new managedClusterSet api
356+
357+
a. `multicloud-operators-foundation` uses managedClusterSet for resource group purpose. So it should only watch the following managedClusterSets:
358+
- `spec.ClusterSelector.SelectorType` is `LegacyClusterSetLabel`
359+
360+
b. `submariner-addon` uses managedClusterSet group clusters based on the network. And in different managedClusterSet, the clusters should be exclusive. So it should only watch the following managedClusterSet:
361+
- `spec.ClusterSelector.SelectorType` is `LegacyClusterSetLabel`
362+
363+
c. `placement` using new `ClusterSelector` to select target clusters.
364+
365+
3. [Implement in OCM 0.8.0] Update full managedClusterSet api and RBAC
366+
```go
367+
type ManagedClusterSetSpec struct {
368+
// Selector represents a selector of ManagedClusters.
332369
ClusterSelector ManagedClusterSelector `json:"clusterSelector"`
333370
}
334371

335372
type ManagedClusterSelector struct{
336373
// "" means to use the current mechanism of matching label <cluster.open-cluster-management.io/clusterset:<ManagedClusterSet Name>.
337-
// (future) "LabelSelector" means to use the LabelSelector to select target managedClusters
374+
// "LegacyClusterSetLabel" means to use label "cluster.open-cluster-management.io/clusterset:<ManagedClusterSet Name>"" to select target clusters.
375+
// "LabelSelector" means to use the LabelSelector to select target managedClusters
338376
// "ExclusiveLabel" means to use a particular cluster label. It is guaranteed that clustersets with same label key are exclusive with each others
339377
// +optional
340378
SelectorType SelectorType `json:"selectorType"`
341379

342380
// ExclusiveLabel defines one label which clusterset could use to select target managedClusters. In this way, we will:
343381
// 1. Guarantee clustersets with same label key are exclusive
344382
// 2. Enable additional permission check when cluster joining/leaving a clusterset (the label key should start with the reserved prefix "cluster.open-cluster-management.io/" and "info.open-cluster-management.io/");
345-
ExclusiveLabel *ExclusiveLabel `json:"exclusiveLabel"`
383+
ExclusiveLabel *ManagedClusterLabel `json:"exclusiveLabel"`
384+
385+
// LabelSelector define the general labelSelector which clusterset will use to select target managedClusters
386+
LabelSelector *metav1.LabelSelector `json:"labelSelector"`
346387
}
347388

348389
type SelectorType string
349390

350391
const (
392+
LabelSelector SelectorType = "LabelSelector"
351393
ExclusiveLabel SelectorType = "ExclusiveLabel"
394+
LegacyClusterSetLabel SelectorType = "LegacyClusterSetLabel"
352395
)
353396

354-
//ExclusiveLabel defines one cluster label
355-
type ExclusiveLabel struct {
356-
//Key is "cluster.open-cluster-management.io/clusterset" by default and can only be cluster.open-cluster-management.io/
397+
//ManagedClusterLabel defines one label
398+
type ManagedClusterLabel struct {
357399
Key string `json:"key"`
358-
//Value can only be empty or the name of the clusterset.
359400
Value string `json:"value"`
360401
}
361402
```
362403

363-
- `LabelSelector` will not be included
364-
- `ExclusiveLabel.Key` must be `cluster.open-cluster-management.io/clusterset` and `ExclusiveLabel.Value` must be `ManagedClusterset Name`
365-
- Both `managedclusterset/join` and `managedclusters/label` permission will be supported
404+
- Support both `join` and `label` permission
366405

367-
2. [Implement in OCM 0.7.0]`multicloud-operators-foundation`, `submariner-addon`, `placement` change the code to integrate with new managedClusterSet api
406+
4. [Implement in OCM 0.8.0] `multicloud-operators-foundation`, `submariner-addon`, `placement` change the code to integrate with new managedClusterSet api
368407

369408
a. `multicloud-operators-foundation` uses managedClusterSet for resource group purpose. So it should only watch the following managedClusterSets:
370-
- `spec.ClusterSelector.SelectorType` is `ExclusiveLabel` and the `ExclusiveLabel.Key` must be `cluster.open-cluster-management.io/clusterset`
371-
- `spec.ClusterSelector.SelectorType` is ""
372-
373-
b. `multicloud-operators-foundation` gives the users `join` permission to a managedClusterSet if the user has "admin" permission to the managedClusterSet. So the `join` permission should be changed with the following rule:
374-
```yaml
375-
- apiGroups: ["cluster.open-cluster-management.io"]
376-
resources: ["managedclusters/label"]
377-
resourceNames: ["cluster.open-cluster-management.io/clusterset:<ManagedClusterSet Name>"]
378-
verbs: ["create"]
379-
```
409+
- `spec.ClusterSelector.SelectorType` is `LegacyClusterSetLabel`
410+
- `spec.ClusterSelector.SelectorType` is `ExclusiveLabel` and `spec.ClusterSelector.ExclusiveLabel.Key` is `cluster.open-cluster-management.io/clusterset`, value is `ManagedClusterSet Name`
380411

381-
c. `submariner-addon` uses managedClusterSet group clusters based on the network. And in different managedClusterSet, the clusters should be exclusive. So it should only watch the following managedClusterSet:
382-
- `spec.ClusterSelector.SelectorType` is `ExclusiveLabel` and the `ExclusiveLabel.Key` must be `cluster.open-cluster-management.io/clusterset`, the `ExclusiveLabel.Value` must be managedClusterSet name.
383-
- `spec.ClusterSelector.SelectorType` is ""
384-
385-
d. `placement` using new `ClusterSelector` to select target clusters.
386-
387-
3. [Implement in OCM 0.8.0] Update full managedClusterSet api and RBAC
388-
- Include `LabelSelector`
389-
- Take off the restriction for “ExclusiveLabel.Key” and “ExclusiveLabel.Value”
390-
- Deprecate `managedclusterset/join` permission
412+
b. `submariner-addon` uses managedClusterSet group clusters based on the network. And in different managedClusterSet, the clusters should be exclusive. So it should only watch the following managedClusterSet:
413+
- `spec.ClusterSelector.SelectorType` is `LegacyClusterSetLabel`
414+
- `spec.ClusterSelector.SelectorType` is `ExclusiveLabel` and `spec.ClusterSelector.ExclusiveLabel.Key` is `cluster.open-cluster-management.io/clusterset`, value is `ManagedClusterSet Name`
391415

392-
4. [Implement in OCM 0.8.0] `placement` uses the new managedClusterSet api to select managedClusters for each managedClusterSet.
416+
c. `placement` using new `ClusterSelector` to select target clusters.
393417

394418
## Upgrade / Downgrade Strategy
395419
The new api is compatible with the previous version. So there is no external work needed when upgrading

enhancements/sig-architecture/30-clusterset-override/metadata.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ approvers:
99
- "@elgnay"
1010
- "@deads2k"
1111
creation-date: 2021-11-30
12-
last-updated: 2022-02-24
12+
last-updated: 2022-04-13
1313
status: provisional

0 commit comments

Comments
 (0)