Skip to content

Commit c861bc9

Browse files
authored
✨ global and per-spoke klusterlet annotations; bump to v0.0.6 (#32)
* feat: global and per-spoke klusterlet annotations * test: global klusterlet annotations, merge precedence * fix: handle nil annotations * fix: singleton -> singletonControlPlane * chore: bump to v0.0.6 * chore: make reviewable * fix: move hubInitializedCond below handleHub --------- Signed-off-by: Tyler Gillson <[email protected]>
1 parent 21c778a commit c861bc9

File tree

12 files changed

+126
-45
lines changed

12 files changed

+126
-45
lines changed

fleetconfig-controller/api/v1alpha1/fleetconfig_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,11 @@ func (j *JoinedSpoke) conditionName() string {
408408

409409
// Klusterlet is the configuration for a klusterlet.
410410
type Klusterlet struct {
411+
// Annotations to apply to the spoke cluster. If not present, the 'agent.open-cluster-management.io/' prefix is added to each key.
412+
// Each annotation is added to klusterlet.spec.registrationConfiguration.clusterAnnotations on the spoke and subsequently to the ManagedCluster on the hub.
413+
// +optional
414+
Annotations map[string]string `json:"annotations,omitempty"`
415+
411416
// A set of comma-separated pairs of the form 'key1=value1,key2=value2' that describe feature gates for alpha/experimental features.
412417
// Options are:
413418
// - AddonManagement (ALPHA - default=true)

fleetconfig-controller/api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 35 additions & 33 deletions
Large diffs are not rendered by default.

fleetconfig-controller/charts/fleetconfig-controller/crds/fleetconfig.open-cluster-management.io-crds.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,13 @@ spec:
347347
default: {}
348348
description: Klusterlet configuration.
349349
properties:
350+
annotations:
351+
additionalProperties:
352+
type: string
353+
description: |-
354+
Annotations to apply to the spoke cluster. If not present, the 'agent.open-cluster-management.io/' prefix is added to each key.
355+
Each annotation is added to klusterlet.spec.registrationConfiguration.clusterAnnotations on the spoke and subsequently to the ManagedCluster on the hub.
356+
type: object
350357
featureGates:
351358
default: AddonManagement=true,ClusterClaim=true
352359
description: |-

fleetconfig-controller/charts/fleetconfig-controller/templates/fleetconfig.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ spec:
3030
bundleVersion: {{ .Values.fleetConfig.source.bundleVersion }}
3131
registry: {{ .Values.fleetConfig.source.registry }}
3232
{{- end }}
33-
{{- if .Values.fleetConfig.hub.singleton }}
34-
singleton: {{- toYaml .Values.fleetConfig.hub.singleton | nindent 6 }}
33+
{{- if .Values.fleetConfig.hub.singletonControlPlane }}
34+
singleton: {{- toYaml .Values.fleetConfig.hub.singletonControlPlane | nindent 6 }}
3535
{{- end }}
3636
createNamespace: {{ .Values.fleetConfig.hub.createNamespace }}
3737
force: {{ .Values.fleetConfig.hub.force }}
@@ -53,6 +53,13 @@ spec:
5353
clusterARN: {{ .clusterARN | quote }}
5454
{{- end }}
5555
klusterlet:
56+
{{- if and .klusterlet.annotations $.Values.fleetConfig.spokeAnnotations }}
57+
annotations: {{- toYaml (merge .klusterlet.annotations $.Values.fleetConfig.spokeAnnotations) | nindent 10 }}
58+
{{- else if .klusterlet.annotations }}
59+
annotations: {{- toYaml .klusterlet.annotations | nindent 10 }}
60+
{{- else if $.Values.fleetConfig.spokeAnnotations }}
61+
annotations: {{- toYaml $.Values.fleetConfig.spokeAnnotations | nindent 10 }}
62+
{{- end }}
5663
mode: {{ .klusterlet.mode | quote }}
5764
purgeOperator: {{ .klusterlet.purgeOperator }}
5865
featureGates: {{ include "featureGates" (dict "dict" $spokeFeatureGates) | quote }}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
fleetConfig:
1111
## @param fleetConfig.enabled Whether to create a FleetConfig resource.
1212
enabled: true
13+
## @param fleetConfig.spokeAnnotations Global annotations to apply to all spoke clusters. If not present, the 'agent.open-cluster-management.io/' prefix is added to each key. Each annotation is added to klusterlet.spec.registrationConfiguration.clusterAnnotations on every spoke and subsequently to the ManagedClusters on the hub. Per-spoke annotations take precedence over the global annotations.
14+
spokeAnnotations: {}
1315
## @descriptionStart
1416
## ### Spoke Feature Gates
1517
## Uncomment and configure `fleetConfig.spokeFeatureGates` to enable feature gates for the Klusterlet on each Spoke.
@@ -157,6 +159,7 @@ fleetConfig:
157159
## @param fleetConfig.spokes[0].ca Hub cluster CA certificate, optional.
158160
## @param fleetConfig.spokes[0].proxyCa Proxy CA certificate, optional.
159161
## @param fleetConfig.spokes[0].proxyUrl URL of a forward proxy server used by agents to connect to the Hub cluster, optional.
162+
## @param fleetConfig.spokes[0].klusterlet.annotations Annotations to apply to the spoke cluster. If not present, the 'agent.open-cluster-management.io/' prefix is added to each key. Each annotation is added to klusterlet.spec.registrationConfiguration.clusterAnnotations on the spoke and subsequently to the ManagedCluster on the hub. These annotations take precedence over the global spoke annotations.
160163
## @param fleetConfig.spokes[0].klusterlet.mode Deployment mode for klusterlet. Options: Default (agents run on spoke cluster) | Hosted (agents run on hub cluster).
161164
## @param fleetConfig.spokes[0].klusterlet.purgeOperator If set, the klusterlet operator will be purged and all open-cluster-management namespaces deleted when the klusterlet is unjoined from its Hub cluster.
162165
## @param fleetConfig.spokes[0].klusterlet.forceInternalEndpointLookup If true, the klusterlet agent will start the cluster registration process by looking for the
@@ -187,6 +190,7 @@ fleetConfig:
187190
proxyUrl: ""
188191
## Configuration for the Klusterlet on the Spoke cluster.
189192
klusterlet:
193+
annotations: {}
190194
mode: "Default"
191195
purgeOperator: true
192196
# Reference the internal endpoint from the cluster-info ConfigMap in the Hub cluster instead of using the Hub's
@@ -269,7 +273,7 @@ imageRegistry: ""
269273
## @param image.pullPolicy Image pull policy
270274
image:
271275
repository: quay.io/open-cluster-management/fleetconfig-controller
272-
tag: v0.0.5
276+
tag: v0.0.6
273277
pullPolicy: IfNotPresent
274278

275279
## @param imagePullSecrets Image pull secrets

fleetconfig-controller/config/crd/bases/fleetconfig.open-cluster-management.io_fleetconfigs.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,13 @@ spec:
337337
default: {}
338338
description: Klusterlet configuration.
339339
properties:
340+
annotations:
341+
additionalProperties:
342+
type: string
343+
description: |-
344+
Annotations to apply to the spoke cluster. If not present, the 'agent.open-cluster-management.io/' prefix is added to each key.
345+
Each annotation is added to klusterlet.spec.registrationConfiguration.clusterAnnotations on the spoke and subsequently to the ManagedCluster on the hub.
346+
type: object
340347
featureGates:
341348
default: AddonManagement=true,ClusterClaim=true
342349
description: |-

fleetconfig-controller/internal/controller/fleetconfig_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,12 @@ func (r *FleetConfigReconciler) Reconcile(ctx context.Context, req ctrl.Request)
138138
}
139139

140140
// Handle Hub cluster: initialization and/or upgrade
141-
hubInitializedCond := fc.GetCondition(v1alpha1.FleetConfigHubInitialized)
142141
if err := handleHub(ctx, r.Client, fc); err != nil {
143142
logger.Error(err, "Failed to handle hub operations")
144143
fc.Status.Phase = v1alpha1.FleetConfigUnhealthy
145144
}
146-
if hubInitializedCond.Status == metav1.ConditionFalse {
145+
hubInitializedCond := fc.GetCondition(v1alpha1.FleetConfigHubInitialized)
146+
if hubInitializedCond == nil || hubInitializedCond.Status == metav1.ConditionFalse {
147147
return ret(ctx, ctrl.Result{Requeue: true}, nil)
148148
}
149149

fleetconfig-controller/internal/controller/spoke.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,10 @@ func joinSpoke(ctx context.Context, kClient client.Client, spec v1alpha1.FleetCo
269269
"--image-registry", spoke.Klusterlet.Source.Registry,
270270
}
271271

272+
for k, v := range spoke.Klusterlet.Annotations {
273+
joinArgs = append(joinArgs, fmt.Sprintf("--klusterlet-annotation=%s=%s", k, v))
274+
}
275+
272276
// resources args
273277
joinArgs = append(joinArgs, common.PrepareResources(spoke.Klusterlet.Resources)...)
274278

fleetconfig-controller/test/data/fleetconfig-values.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
fleetConfig:
2+
spokeAnnotations:
3+
foo: "not-bar"
4+
baz: "quux"
25
spokes:
36
- name: hub-as-spoke
47
createNamespace: true
@@ -21,6 +24,8 @@ fleetConfig:
2124
namespace: "default"
2225
kubeconfigKey: "value"
2326
klusterlet:
27+
annotations:
28+
foo: "bar"
2429
mode: "Default"
2530
purgeOperator: true
2631
forceInternalEndpointLookup: true

0 commit comments

Comments
 (0)