Skip to content

Commit 44e7f85

Browse files
feat: Add bootstrapLocalCluster option to FleetAddonConfig (#308)
Introduces a new boolean field `bootstrapLocalCluster` to the FleetAddonConfig CRD spec. This option controls the auto-installation of a fleet agent in the local cluster. The controller logic is updated to read and utilize this new configuration value. Signed-off-by: Danil-Grigorev <[email protected]>
1 parent 295b2c1 commit 44e7f85

File tree

5 files changed

+423
-70
lines changed

5 files changed

+423
-70
lines changed

config/crds/fleet-addon-config.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ spec:
263263
config:
264264
nullable: true
265265
properties:
266+
bootstrapLocalCluster:
267+
description: Enable auto-installation of a fleet agent in the local cluster.
268+
nullable: true
269+
type: boolean
266270
featureGates:
267271
description: feature gates controlling experimental features
268272
nullable: true
@@ -369,7 +373,6 @@ spec:
369373
type: string
370374
type: object
371375
type: object
372-
x-kubernetes-validations: []
373376
status:
374377
nullable: true
375378
properties:
@@ -412,7 +415,7 @@ spec:
412415
type: object
413416
required:
414417
- spec
415-
title: FleetAddonConfig_kube_validation
418+
title: FleetAddonConfigValidated
416419
type: object
417420
x-kubernetes-validations:
418421
- rule: self.metadata.name == 'fleet-addon-config'

docs/src/04_reference/01_import-strategy.md

Lines changed: 2 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ CAAPF follows a simple import strategy for CAPI clusters:
44

55
1. Each CAPI cluster has a corresponding Fleet `Cluster` object.
66
2. Each CAPI Cluster Class has a corresponding Fleet `ClusterGroup` object.
7-
3. When a CAPI `Cluster` references a `ClusterClass` in a different namespace, a `ClusterGroup` is created in the `Cluster` namespace. This `ClusterGroup` targets all clusters in this namespace that reference the same `ClusterClass`. See the [configuration](#cluster-clustergroupbundlenamespacemapping-configuration) section for details.
7+
3. When a CAPI `Cluster` references a `ClusterClass` in a different namespace, a `ClusterGroup` is created in the `Cluster` namespace. This `ClusterGroup` targets all clusters in this namespace that reference the same `ClusterClass`. See the [configuration](03_fleet-addon-config#applyclassgroup) section for details.
88
4. If at least one CAPI `Cluster` references a `ClusterClass` in a different namespace, a [`BundleNamespaceMapping`][mapping] is created in the `ClusterClass` namespace. This allows Fleet `Cluster` resources to use application sources such as `Bundles`, `HelmApps`, or `GitRepos` from the `ClusterClass` namespace as if they were deployed in the `Cluster` namespace. See the [configuration](#cluster-clustergroupbundlenamespacemapping-configuration) section for details.
99

1010
[mapping]: https://fleet.rancher.io/namespaces#cross-namespace-deployments
1111

12-
**By default, `CAAPF` imports all `CAPI` clusters under Fleet management. See the next section for configuration details.**
12+
**By default, `CAAPF` imports all `CAPI` clusters under Fleet management. See the [configuration](03_fleet-addon-config.md#applyclassgroup) section for details.**
1313

1414
![CAAPF-import-groups excalidraw dark](https://github.com/rancher-sandbox/cluster-api-addon-provider-fleet/assets/32226600/0e0bf58d-7030-491e-976e-8363023f0c88)
1515

@@ -24,68 +24,3 @@ When a CAPI `Cluster` references a `ClusterClass`, `CAAPF` applies two specific
2424

2525
- `clusterclass-name.fleet.addons.cluster.x-k8s.io: <class-name>`
2626
- `clusterclass-namespace.fleet.addons.cluster.x-k8s.io: <class-ns>`
27-
28-
## Configuration
29-
30-
`FleetAddonConfig` provides several configuration options to define which clusters to import.
31-
32-
### Cluster `ClusterGroup`/`BundleNamespaceMapping` Configuration
33-
34-
When a CAPI `Cluster` references a `ClusterClass` in a different namespace, a corresponding `ClusterGroup` is created in the **`Cluster`** namespace. This ensures that all clusters within the namespace that share the same `ClusterClass` from another namespace are grouped together.
35-
36-
This `ClusterGroup` inherits `ClusterClass` labels and applies two `CAAPF`-specific labels to uniquely identify the group within the cluster scope:
37-
38-
- `clusterclass-name.fleet.addons.cluster.x-k8s.io: <class-name>`
39-
- `clusterclass-namespace.fleet.addons.cluster.x-k8s.io: <class-ns>`
40-
41-
Additionally, this configuration enables the creation of a `BundleNamespaceMapping`. This mapping selects all available bundles and establishes a link between the namespace of the `Cluster` and the namespace of the referenced `ClusterClass`. This allows the Fleet `Cluster` to be evaluated as a target for application sources such as `Bundles`, `HelmApps`, or `GitRepos` from the **`ClusterClass`** namespace.
42-
43-
When all CAPI `Cluster` resources referencing the same `ClusterClass` are removed, both the `ClusterGroup` and `BundleNamespaceMapping` are cleaned up.
44-
45-
To enable this behavior, configure `FleetAddonConfig` as follows:
46-
47-
```yaml
48-
apiVersion: addons.cluster.x-k8s.io/v1alpha1
49-
kind: FleetAddonConfig
50-
metadata:
51-
name: fleet-addon-config
52-
spec:
53-
cluster:
54-
applyClassGroup: true
55-
```
56-
57-
Setting `applyClassGroup: true` ensures that Fleet automatically creates a `ClusterGroup` object for each `Cluster` resource and applies the necessary `BundleNamespaceMapping` for cross-namespace bundle access.
58-
59-
**Note: If the `cluster` field is not set, this setting is enabled by default.**
60-
61-
### Namespace Label Selection
62-
63-
This configuration defines how to select namespaces based on specific labels. The `namespaceSelector` field ensures that the import strategy applies only to namespaces that have the label `import: "true"`. This is useful for scoping automatic import to specific namespaces rather than applying it cluster-wide.
64-
65-
```yaml
66-
apiVersion: addons.cluster.x-k8s.io/v1alpha1
67-
kind: FleetAddonConfig
68-
metadata:
69-
name: fleet-addon-config
70-
spec:
71-
cluster:
72-
namespaceSelector:
73-
matchLabels:
74-
import: "true"
75-
```
76-
77-
### Cluster Label Selection
78-
79-
This configuration filters clusters based on labels, ensuring that the `FleetAddonConfig` applies only to clusters with the label `import: "true"`. This allows more granular per-cluster selection across the cluster scope.
80-
81-
```yaml
82-
apiVersion: addons.cluster.x-k8s.io/v1alpha1
83-
kind: FleetAddonConfig
84-
metadata:
85-
name: fleet-addon-config
86-
spec:
87-
cluster:
88-
selector:
89-
matchLabels:
90-
import: "true"
91-
```

0 commit comments

Comments
 (0)