Repository navigation
Allow configuring workload annotations and certificate duration - #92
martin-briatka wants to merge 2 commits into
Conversation
30b2b84 to
03c8dcf
Compare
Add a spec.annotations (map[string]string) field. The operator merges its entries onto the metadata of every generated StatefulSet. The merge is done in the operator rather than in the chart templates, so it is independent of the vendored chart. The field is empty by default, so existing deployments are unaffected.
03c8dcf to
a430f76
Compare
|
Please, also add possibility to specify certificate duration as described in: #65 |
Add an optional spec.tls.duration field that is passed through to the generated cert-manager Certificate. When unset, the previous hard-coded default of 876000h (~100 years) is preserved, so existing Valkey resources are unaffected. Closes SAP#65
|
Why don't we just use the chart's |
Hi @cbarbian-sap, podAnnotations lands on spec.template.metadata.annotations (pod template), not on the StatefulSet's own metadata.annotations. The reloader we use reads the trigger only from the workload's top-level metadata, so podAnnotations has no effect. commonAnnotations does reach the top-level but stamps every chart object (Service, SA, PVC, headless service), not just StatefulSets. This PR adds spec.annotations which places annotations directly on the StatefulSet metadata - currently not possible via the CR at all. |
Summary
This PR adds two related but independent configuration options, both coming out of #65.
Workload annotations
Add a
spec.annotations(map[string]string) field. The operator merges its entries onto the metadata of every generated StatefulSet (primary, replica and sentinel), so users can attach arbitrary annotations to the workload.The merge is performed in the operator (a generator wrapper), not in the chart templates, so it is independent of the vendored chart, the same way
TopologySpreadConstraintsare already injected today. The field is empty by default, so existing deployments are unaffected.Certificate duration
Add a
spec.tls.durationfield that is passed through to the generated cert-manager Certificate. When unset, the previous default of876000h(~100 years) is preserved, so existing resources are unaffected.Changes
api/v1alpha1/types.go:Annotations map[string]stringonValkeySpec, andDuration *metav1.DurationonTLSPropertiesinternal/transformer/annotation_generator.go: generator wrapper that readsspec.annotationsand merges them onto every generated StatefulSet's metadatapkg/operator/operator.go: wrap the resource generator with the annotation generatorpkg/operator/data/parameters.yaml: passspec.tls.durationto the Certificate, defaulting to876000hwhen unsetapi/v1alpha1/zz_generated.deepcopy.go+crds/cache.cs.sap.com_valkeys.yaml: regenerated viamake generate manifestsTesting
go buildandgo vetpass.spec.annotationsset, the operator writes the annotation onto the generated StatefulSet. Combined with a pod-reloader annotation referencing the TLS secret, the reloader then manages the workload and restarts the pod when that secret changes, so Valkey picks up a rotated certificate (the concern raised in [FEATURE] make cert-manager Certificate duration configurable #65).