You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An initial implementation of maintenance windows is to introduce their specification on a weekly basis. In the future we might provide more control, including specification of an actual day.
Maintenance windows are enabled only for the “unsupervised” primary update strategy, with “restart” method option. When a maintenance window is defined in a cluster, an update of the image is “postponed” to the first available maintenance window, which will trigger a rollout update.
A maintenance window has a minimal length of "w" hours (initially 6), in which activities cannot start any later than "w - s" hours, where "s" is expressed in hours (by default 3). So, for example, with w=6h and s=3, activities can only start in the first 3 hours of the maintenance window.
My team and I would find this quite useful. It is pretty disruptive that upgrading the operator or upgrading an image in the cluster image catalog leads to a rolling restart of all cloudnative-pg clusters managed by the operator. Not impossible to handle, but we'd really rather avoid a restart-the-world scenario if possible. It would be nice to define a maintenance window such that these rolling restarts can only happen during specific times. Then we can default randomize these times across cloudnative-pg clusters, or let individual database owners specify particular maintenance windows.
We envision a large fleet of DB clusters in dedicated namespaces for each application and segregated by environment layer DEV / TEST / QA / PROD .
I considered heavily the pros and cons of the ClusterImageCatalog and ImageCatalog approaches: while I'm all for simplicity, we cannot afford to affect all DB clusters at once for all apps when we update the ClusterImageCatalog, even with distinct prod and non-prod k8s clusters. Blast radius is too wide for our risk appetite.
Therefore we define ImageCatalog resources in each application namespace, and we (the DB infra team) update its contents through automation (gitops). As of now, the clusters are immediately updated. That's about enforcement of patching controls as part of the platform contract we define with our customers (the app teams).
Like @alexklibisz , we can handle this scenario by controlling in our automation the timing of the ImageCatalog in each namespace. But I feel it would be much nicer to have everything defined within the cluster manifest, or through another CRD similar to ScheduledBackups for example.
And it would provide a consistent experience for the app teams: everything is defined through CNPG.
@gbartolini : would you agree to reopen this issue ? Or shall I create a new feature request and reference this one ?
@gbartolini, This makes sense especially with the introduction of ImageCatalog / ClusterImageCatalog, where new PostgreSQL images can become available at any time.
For an initial implementation, it seems reasonable to:
Define maintenance windows at the Cluster CRD level, since they describe when a specific cluster is allowed to restart, not which images exist.
Apply maintenance windows only when primaryUpdateStrategy is unsupervised and the update method is restart.
When a new image is detected outside a maintenance window, postpone the rollout and trigger it during the first available maintenance window.
Keep supervised strategy behavior unchanged.
This would provide predictable, enterprise-friendly upgrade timing while keeping the initial scope small and aligned with existing controller logic.
Besides (only) time-based, I think it would be awesome to be able to gate a maintenanceWindow on other factors too - perhaps even an arbitrary CEL expression against other cluster resources. What I'm envisioning is for example to prevent any rollouts while a workload is busy running migrations.
Activity
gbartolini commentedon Feb 5, 2024
This should be depending on #12
github-actions commentedon Feb 5, 2025
This issue is stale because it has been open for 60 days with no activity.
github-actions commentedon Feb 20, 2025
This issue was closed because it has been inactive for 14 days since being marked as stale.
chore(deps): update docker digest to d743877 (cloudnative-pg#14)
alexklibisz commentedon Jun 16, 2025
My team and I would find this quite useful. It is pretty disruptive that upgrading the operator or upgrading an image in the cluster image catalog leads to a rolling restart of all cloudnative-pg clusters managed by the operator. Not impossible to handle, but we'd really rather avoid a restart-the-world scenario if possible. It would be nice to define a maintenance window such that these rolling restarts can only happen during specific times. Then we can default randomize these times across cloudnative-pg clusters, or let individual database owners specify particular maintenance windows.
LaurentP-Pro commentedon Nov 15, 2025
Hello,
We would also benefit from such a feature.
We envision a large fleet of DB clusters in dedicated namespaces for each application and segregated by environment layer DEV / TEST / QA / PROD .
I considered heavily the pros and cons of the ClusterImageCatalog and ImageCatalog approaches: while I'm all for simplicity, we cannot afford to affect all DB clusters at once for all apps when we update the ClusterImageCatalog, even with distinct prod and non-prod k8s clusters. Blast radius is too wide for our risk appetite.
Therefore we define ImageCatalog resources in each application namespace, and we (the DB infra team) update its contents through automation (gitops). As of now, the clusters are immediately updated. That's about enforcement of patching controls as part of the platform contract we define with our customers (the app teams).
Like @alexklibisz , we can handle this scenario by controlling in our automation the timing of the ImageCatalog in each namespace. But I feel it would be much nicer to have everything defined within the cluster manifest, or through another CRD similar to ScheduledBackups for example.
And it would provide a consistent experience for the app teams: everything is defined through CNPG.
@gbartolini : would you agree to reopen this issue ? Or shall I create a new feature request and reference this one ?
gaurangkudale commentedon Dec 27, 2025
@gbartolini, This makes sense especially with the introduction of
ImageCatalog/ClusterImageCatalog, where new PostgreSQL images can become available at any time.For an initial implementation, it seems reasonable to:
primaryUpdateStrategyisunsupervisedand the update method isrestart.This would provide predictable, enterprise-friendly upgrade timing while keeping the initial scope small and aligned with existing controller logic.
Example Cluster CRD
High-Level Design
The operator detects a new PostgreSQL image via ImageCatalog
If inside maintenance windw:
If outside any maintenance window:
At the first available maintenance window:
After completion:
thomasboussekey commentedon Apr 13, 2026
Hello,
Interesting feature!
My 2 pence thought on this would be to change maintenance definition from multiple entries to a cron-defined timestamp:
bo0tzz commentedon Jun 30, 2026
Besides (only) time-based, I think it would be awesome to be able to gate a maintenanceWindow on other factors too - perhaps even an arbitrary CEL expression against other cluster resources. What I'm envisioning is for example to prevent any rollouts while a workload is busy running migrations.