Skip to content

Allow configuring workload annotations and certificate duration - #92

Draft
martin-briatka wants to merge 2 commits into
SAP:mainfrom
martin-briatka:feat/workload-annotations
Draft

martin-briatka wants to merge 2 commits into
SAP:mainfrom
martin-briatka:feat/workload-annotations

Conversation

@martin-briatka

@martin-briatka martin-briatka commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

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 TopologySpreadConstraints are already injected today. The field is empty by default, so existing deployments are unaffected.

spec:
  annotations:
    example.io/some-annotation: "value"

Certificate duration

Add a spec.tls.duration field that is passed through to the generated cert-manager Certificate. When unset, the previous default of 876000h (~100 years) is preserved, so existing resources are unaffected.

spec:
  tls:
    enabled: true
    duration: 8760h

Changes

  • api/v1alpha1/types.go: Annotations map[string]string on ValkeySpec, and Duration *metav1.Duration on TLSProperties
  • internal/transformer/annotation_generator.go: generator wrapper that reads spec.annotations and merges them onto every generated StatefulSet's metadata
  • pkg/operator/operator.go: wrap the resource generator with the annotation generator
  • pkg/operator/data/parameters.yaml: pass spec.tls.duration to the Certificate, defaulting to 876000h when unset
  • api/v1alpha1/zz_generated.deepcopy.go + crds/cache.cs.sap.com_valkeys.yaml: regenerated via make generate manifests

Testing

  • go build and go vet pass.
  • Validated end-to-end on a live cluster: with spec.annotations set, 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).

@martin-briatka
martin-briatka force-pushed the feat/workload-annotations branch 2 times, most recently from 30b2b84 to 03c8dcf Compare November 9, 2026 13:32
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.
@martin-briatka
martin-briatka force-pushed the feat/workload-annotations branch from 03c8dcf to a430f76 Compare November 9, 2026 13:47
@martin-briatka
martin-briatka marked this pull request as ready for review November 12, 2026 10:12
@boribas

boribas commented Nov 12, 2026

Copy link
Copy Markdown

Please, also add possibility to specify certificate duration as described in: #65

@martin-briatka
martin-briatka removed the request for review from cbarbian-sap November 12, 2026 14:34
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
@martin-briatka martin-briatka changed the title Allow configuring additional annotations on the generated workload Allow configuring workload annotations and certificate duration Nov 12, 2026
@martin-briatka
martin-briatka marked this pull request as draft November 12, 2026 15:03
@cbarbian-sap

Copy link
Copy Markdown
Contributor

@martin-briatka

Copy link
Copy Markdown
Contributor Author

Why don't we just use the chart's podAnnotations: https://github.com/bitnami/charts/blob/main/bitnami/valkey-cluster/templates/valkey-statefulset.yaml#L38-L40?

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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants