zalando / postgres-operator

Postgres operator creates and manages PostgreSQL clusters running in Kubernetes
https://postgres-operator.readthedocs.io/
MIT License
4.11k stars 949 forks source link

Improving Postgres CR Status with Additional Details #2669

Open ravina-c opened 2 weeks ago

ravina-c commented 2 weeks ago

Hi, Currently the status field of the postgresql CR looks something like:

status:
  PostgresClusterStatus: Running

I'd like to propose following changes to the status:

post these changes, the status field of the postgresql CR would look something like this:

status:
  labelSelector: cluster-name=postgres-cluster-pvc-5
  numberOfInstances: 3
  conditions:
  - lastTransitionTime: "2024-06-03T10:18:04Z"
    status: "True"
    type: postgresClusterStatusRunning
  observedGeneration: 2

Along with this, I am proposing to add scale subresource in the CRD of postgresql as well, which would use some of the fields proposed above, and then this scale subresource can be further used by external systems to scale or monitor the CR. This scale subresource would look something like this:

 subresources:
   status: {}
   scale:
       specReplicasPath: .spec.numberOfInstances  
       statusReplicasPath: .status.numberOfInstances  
       labelSelectorPath: .status.labelSelector
FxKu commented 1 week ago

1698 just for reference. I would be happy to help and review a PR.

Let's start small first and have maybe only observedGeneration (because it was also mentioned in #1698) and lastTransitionTime - I would also need to look up which status fields K8s currently recommends. I think, showing status of child resources could also be useful. But let's start small first and also be backwards compatible with the current status field.

ravina-c commented 1 week ago

Sure, I am working on the code changes, will submit a draft PR soon.

/assign