Skip to content

Commit 2845d9e

Browse files
authored
✨ separate create topology resources flag from create FleetConfig flag (#21)
* feat: Helm flag for topology resources, separate from FleetConfig creation Signed-off-by: Tyler Gillson <[email protected]> * chore: cleanup remaining multicluster refs & rename vars Signed-off-by: Tyler Gillson <[email protected]> * chore: final variable cleanup Signed-off-by: Tyler Gillson <[email protected]> --------- Signed-off-by: Tyler Gillson <[email protected]>
1 parent 279c4fe commit 2845d9e

File tree

10 files changed

+167
-155
lines changed

10 files changed

+167
-155
lines changed

fleetconfig-controller/api/v1alpha1/fleetconfig_webhook.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -85,46 +85,46 @@ var _ webhook.CustomValidator = &FleetConfigCustomValidator{}
8585

8686
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
8787
func (v *FleetConfigCustomValidator) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
88-
mc, ok := obj.(*FleetConfig)
88+
fc, ok := obj.(*FleetConfig)
8989
if !ok {
9090
return nil, fmt.Errorf("expected a FleetConfig object but got %T", obj)
9191
}
92-
log.Info("Validation for FleetConfig upon creation", "name", mc.GetName())
92+
log.Info("Validation for FleetConfig upon creation", "name", fc.GetName())
9393

9494
var (
9595
allErrs field.ErrorList
9696
warnings admission.Warnings
9797
)
9898

99-
if valid, msg := isKubeconfigValid(mc.Spec.Hub.Kubeconfig); !valid {
99+
if valid, msg := isKubeconfigValid(fc.Spec.Hub.Kubeconfig); !valid {
100100
allErrs = append(allErrs, field.Invalid(
101-
field.NewPath("hub"), mc.Spec.Hub.Kubeconfig, msg),
101+
field.NewPath("hub"), fc.Spec.Hub.Kubeconfig, msg),
102102
)
103103
}
104104

105-
for i, spoke := range mc.Spec.Spokes {
105+
for i, spoke := range fc.Spec.Spokes {
106106
if spoke.Klusterlet.Mode == string(operatorv1.InstallModeHosted) {
107107
if spoke.Klusterlet.ManagedClusterKubeconfig == nil {
108108
allErrs = append(allErrs, field.Invalid(
109-
field.NewPath("spokes").Index(i), mc.Spec.Spokes, "managedClusterKubeconfig is required in hosted mode"),
109+
field.NewPath("spokes").Index(i), fc.Spec.Spokes, "managedClusterKubeconfig is required in hosted mode"),
110110
)
111111
} else {
112112
if valid, msg := isKubeconfigValid(spoke.Klusterlet.ManagedClusterKubeconfig); !valid {
113113
allErrs = append(allErrs, field.Invalid(
114-
field.NewPath("spokes").Index(i), mc.Spec.Spokes, msg),
114+
field.NewPath("spokes").Index(i), fc.Spec.Spokes, msg),
115115
)
116116
}
117117
}
118118
}
119119
if valid, msg := isKubeconfigValid(spoke.Kubeconfig); !valid {
120120
allErrs = append(allErrs, field.Invalid(
121-
field.NewPath("spokes").Index(i), mc.Spec.Spokes, msg),
121+
field.NewPath("spokes").Index(i), fc.Spec.Spokes, msg),
122122
)
123123
}
124124
}
125125

126126
if len(allErrs) > 0 {
127-
return warnings, errors.NewInvalid(GroupKind, mc.Name, allErrs)
127+
return warnings, errors.NewInvalid(GroupKind, fc.Name, allErrs)
128128
}
129129

130130
return warnings, nil
@@ -142,32 +142,32 @@ func isKubeconfigValid(kubeconfig *Kubeconfig) (bool, string) {
142142

143143
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
144144
func (v *FleetConfigCustomValidator) ValidateUpdate(_ context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) {
145-
mc, ok := newObj.(*FleetConfig)
145+
fc, ok := newObj.(*FleetConfig)
146146
if !ok {
147147
return nil, fmt.Errorf("expected a FleetConfig object for the newObj but got %T", newObj)
148148
}
149-
oldMC, ok := oldObj.(*FleetConfig)
149+
oldFc, ok := oldObj.(*FleetConfig)
150150
if !ok {
151151
return nil, fmt.Errorf("expected a FleetConfig object for the oldObj but got %T", oldObj)
152152
}
153-
log.Info("starting validation for FleetConfig update", "name", mc.GetName())
153+
log.Info("starting validation for FleetConfig update", "name", fc.GetName())
154154

155-
err := allowFleetConfigUpdate(mc, oldMC)
155+
err := allowFleetConfigUpdate(fc, oldFc)
156156
if err != nil {
157157
return nil, err
158158
}
159159

160-
log.Info("validation for FleetConfig update allowed", "name", mc.GetName())
160+
log.Info("validation for FleetConfig update allowed", "name", fc.GetName())
161161
return nil, nil
162162
}
163163

164164
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
165165
func (v *FleetConfigCustomValidator) ValidateDelete(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
166-
mc, ok := obj.(*FleetConfig)
166+
fc, ok := obj.(*FleetConfig)
167167
if !ok {
168168
return nil, fmt.Errorf("expected a FleetConfig object but got %T", obj)
169169
}
170-
log.Info("Validation for FleetConfig upon deletion", "name", mc.GetName())
170+
log.Info("Validation for FleetConfig upon deletion", "name", fc.GetName())
171171

172172
// TODO(user): fill in your validation logic upon object deletion.
173173
return nil, nil

fleetconfig-controller/charts/fleetconfig-controller/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ Refer to the [Multicluster Controlplane configuration](https://github.com/open-c
6767

6868
| Name | Description | Value |
6969
| --------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------- |
70-
| `fleetConfig.enabled` | Whether to install fleetconfig-controller. | `true` |
70+
| `fleetConfig.enabled` | Whether to create a FleetConfig resource. | `true` |
7171
| `fleetConfig.spokeFeatureGates.ClusterClaim` | ClusterClaim feature gate (ALPHA - default=true). Enables cluster claim functionality. | `true` |
7272
| `fleetConfig.spokeFeatureGates.RawFeedbackJsonString` | RawFeedbackJsonString feature gate (ALPHA - default=false). Enables raw feedback JSON string support. | `true` |
7373
| `fleetConfig.source.bundleVersion` | Bundle version. | `v1.0.0` |
7474
| `fleetConfig.source.registry` | Image registry. | `quay.io/open-cluster-management` |
7575
| `fleetConfig.hub.clusterManager.featureGates.DefaultClusterSet` | DefaultClusterSet feature gate. | `true` |
7676
| `fleetConfig.hub.clusterManager.featureGates.ManifestWorkReplicaSet` | ManifestWorkReplicaSet feature gate. | `true` |
7777
| `fleetConfig.hub.clusterManager.featureGates.ResourceCleanup` | ResourceCleanup feature gate. | `true` |
78-
| `fleetConfig.hub.clusterManager.purgeOperator` | If set, the cluster manager operator will be purged and the open-cluster-management namespace deleted when the MultiCluster CR is deleted. | `true` |
78+
| `fleetConfig.hub.clusterManager.purgeOperator` | If set, the cluster manager operator will be purged and the open-cluster-management namespace deleted when the FleetConfig CR is deleted. | `true` |
7979
| `fleetConfig.hub.clusterManager.resources` | Resource specifications for all clustermanager-managed containers. | `{}` |
8080
| `fleetConfig.hub.createNamespace` | If true, create open-cluster-management namespace, otherwise use existing one. | `true` |
8181
| `fleetConfig.hub.force` | If set, the hub will be reinitialized. | `false` |
@@ -97,6 +97,12 @@ Refer to the [Multicluster Controlplane configuration](https://github.com/open-c
9797
| `fleetConfig.spokes[0].klusterlet.resources` | Resource specifications for all klusterlet-managed containers. | `{}` |
9898
| `fleetConfig.spokes[0].klusterlet.singleton` | If true, deploy klusterlet in singleton mode, with registration and work agents running in a single pod. This is an alpha stage flag. | `false` |
9999

100+
### Topology Resources
101+
102+
| Name | Description | Value |
103+
| --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ |
104+
| `topologyResources.enabled` | Whether to create Namespaces and ManagedClusterSetBindings for the default ManagedClusterSets created when a FleetConfig is created with the DefaultClusterSet feature gate enabled. Additionally, a Namespace, ManagedClusterSet, and Placement are created for targeting all managed clusters that are not the hub running in hub-as-spoke mode. | `true` |
105+
100106
### fleetconfig-controller parameters
101107

102108
| Name | Description | Value |

fleetconfig-controller/charts/fleetconfig-controller/templates/ocm/topology-resources.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if index .Values "fleetConfig" "enabled" }}
1+
{{- if index .Values "topologyResources" "enabled" }}
22
# managed-cluster-set-global always includes all ManagedClusters.
33
apiVersion: v1
44
kind: Namespace

fleetconfig-controller/charts/fleetconfig-controller/values.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
## Configuration for the FleetConfig resource created on the Hub. By default, bootstraps the Hub cluster in hub-as-spoke mode.
99
## @descriptionEnd
1010
fleetConfig:
11-
## @param fleetConfig.enabled Whether to install fleetconfig-controller.
11+
## @param fleetConfig.enabled Whether to create a FleetConfig resource.
1212
enabled: true
1313
## @descriptionStart
1414
## ### Spoke Feature Gates
@@ -80,7 +80,7 @@ fleetConfig:
8080
ManifestWorkReplicaSet: true
8181
## @param fleetConfig.hub.clusterManager.featureGates.ResourceCleanup ResourceCleanup feature gate.
8282
ResourceCleanup: true
83-
## @param fleetConfig.hub.clusterManager.purgeOperator If set, the cluster manager operator will be purged and the open-cluster-management namespace deleted when the MultiCluster CR is deleted.
83+
## @param fleetConfig.hub.clusterManager.purgeOperator If set, the cluster manager operator will be purged and the open-cluster-management namespace deleted when the FleetConfig CR is deleted.
8484
purgeOperator: true
8585
## @param fleetConfig.hub.clusterManager.resources Resource specifications for all clustermanager-managed containers.
8686
resources: {}
@@ -225,6 +225,12 @@ fleetConfig:
225225
# qosClass: "Default"
226226
singleton: false
227227

228+
## @section Topology Resources
229+
230+
## @param topologyResources.enabled Whether to create Namespaces and ManagedClusterSetBindings for the default ManagedClusterSets created when a FleetConfig is created with the DefaultClusterSet feature gate enabled. Additionally, a Namespace, ManagedClusterSet, and Placement are created for targeting all managed clusters that are not the hub running in hub-as-spoke mode.
231+
topologyResources:
232+
enabled: true
233+
228234
## @section fleetconfig-controller parameters
229235

230236
## @param kubernetesProvider Kubernetes provider of the cluster that fleetconfig-controller will be installed on. Valid values are "Generic", "EKS", "GKE".

0 commit comments

Comments
 (0)