Repository navigation
Unifying Cluster initialisation, recovery, and scaling
#9176
Replies: 3 comments
|
I think its a good idea. I'd also like to pitch the possibility to programmatically control this via e.g a ValidateCreateCluster/MutateCluster gRPC which could evaluate whether the cluster should be started based on day-2, or a day-1 config. |
|
I agree with this proposal. In my experience, from a more "ops" perspective, having to deal with multiple yaml files, is never nice mostly because in a situation of real downtime to piece together the relative restore manifest is never easy, not to mention the fact that we have to remember switching s3 backup folder to avoid risk of overwriting data. the following is pure brainstorming, ignorable: |
|
So, in a way, this is like a Deployment to a ReplicaSet? I fully agree with this idea |
Uh oh!
There was an error while loading. Please reload this page.
Currently, CloudNativePG has two mutually exclusive bootstrap methods for a new cluster:
initdb(for a new empty cluster) andrecovery(for a cluster restored from a backup or another live cluster). Both methods assume the cluster is being created "from scratch," even if it's meant to replace an existing one (e.g., for PITR following a data loss scenario).This "from scratch" methodology is not an accident; it's a direct result of the project's history and prioritised growth. We have heavily favoured the "cattle, not pets" model, where any cluster can be terminated and recreated from scratch. This was, and still is, a powerful and robust approach for initial provisioning and basic scaling.
However, as CloudNativePG matures and our users deploy it in more complex, stateful scenarios (like strict GitOps workflows and demanding business continuity), the limitations of a purely cattle-based model are becoming clearer. A cluster that has existed for some time shouldn't be treated the same as a brand-new one, especially during a Point-in-Time Recovery (PITR) operation where its existing data is highly valuable.
This discussion aims to explore those specific limitations and propose a more flexible model that blends the best of both worlds.
Current challenges
The hard distinction between
initdbandrecoveryat the cluster's bootstrap phase is the root of a few issues:Lack of idempotency: in a GitOps environment, a
Clusterresource should be idempotent. If we need to perform a PITR on an existing cluster, the current process (deleting/recreating theClusterresource) results in a new cluster from the operator's perspective. This is not idempotent and can break external references, monitoring, and replica cluster definitions that point to the "old" cluster.Inefficient PITR: because a PITR is treated as a "new cluster" creation, we cannot perform an incremental copy or a rewind-like operation on an existing cluster's PVCs. We are forced to re-stream or re-copy the entire dataset, even if the existing PVCs are 99% up-to-date.
Code and logic duplication: the
recoveryprocess (usingpg_basebackupfrom a live source) is functionally identical to the process for scaling up by adding a new replica. We have duplicated this "clone from primary" logic in two different parts of the operator's workflow (bootstrap vs. scaling).Inflexible scaling strategy: scaling from 0 nodes (
bootstrap) and scaling from 1 node (adding a replica) should be part of the same conceptual process. However, we currently have no control over how a new replica is created. It's always apg_basebackupfrom the primary. We should be able to decide the source for any new instance (primary or replica).Proposal of a unified "Instance Provisioning" model
This discussion aims to brainstorm a unified provisioning model, where creating any instance (whether it's the first, a new primary, or a replica) is driven by the same unified logic. This implies we should move away from the rigid, mutually-exclusive
bootstrapsection.In this new model, the operator's primary job would be to ensure a
Podand itsPVCexist and have the correct data. The source of that data should be a flexible, configurable strategy defined directly in theClusterspec.Here are a few starting points to seed the discussion (this list is not exhaustive):
Handling existing dstate:
pg_rewind, or re-use).Defining the data source:
Provisioning methods & capabilities:
...and more.
Let the discussion begin.
All reactions