Skip to content

Conversation

@mikkeloscar
Copy link
Member

@mikkeloscar mikkeloscar commented Dec 4, 2025

Similar to #3004 this introduces CRD (yaml) generation based on the go structs using controler-gen

This enables the generation of the postgresql CRD.

The PR has two commits:

  • Sort postgresql.crd.yaml this just sorts the yaml keys similar to the CRD generation does, but doesn't change the yaml from what is in master. This is just done to make the diff cleaner
  • Generate postgresql CRD from go structs this includes the new YAML generated from the go structs. Look at this commit to see how it's different from master.

As this goes from a "manually" defined schema to a generated one there are a few changes:

  • The field patroni.maximum_lag_on_failover was changed from float32 to int64 as it was defined as integer in the schema. Related code was changed to cast to float32.
  • Enum for tolerations are not generated from upstream types, not simple to fix without copying the whole upstream structure.
  • Types of the structure map[string][]string allowed nullable of the []string. This is not possible to set in kubebuilder so it's missing meaning you can't do key: null in those cases, which I anyway thing is better to not allow.
  • A few constraints are not possible to define via kubebuilder markers. Namely oneOf on the standby field and specifying maintenanceWindows field as a list of strings (as opposed to a list of objects). To handle this I have added a custom script hack/adjust_postgresql_crd.sh which injects the right settings via sed after the manifest is generated. This is intended to be temporary until those features are supported upstream by controller-gen.

TODO:

  • Fix types for maintenanceWindows (this uses a string in the yaml, but a go struct in code)
  • Enable full schema generation for big fields which was left out initially to make it simpler to view the diff:
    • sidecars
    • initContainers
    • env
    • init_containers
  • Handle oneOf on the standby field
  • Validate new schema against existing resources across Zalando clusters to ensure it will continue to work.

Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
@mikkeloscar mikkeloscar added do-not-merge major Major feature changes or updates, e.g. feature rollout to a new country, new API calls. labels Dec 4, 2025
@mikkeloscar mikkeloscar force-pushed the gen-crds-postgresql branch 4 times, most recently from bd1fe37 to 1f0c0be Compare December 4, 2025 15:25
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge major Major feature changes or updates, e.g. feature rollout to a new country, new API calls.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants