diff --git a/docs/user.md b/docs/user.md index 108ffa574..0ec46645a 100644 --- a/docs/user.md +++ b/docs/user.md @@ -268,6 +268,7 @@ spec: Things to note: - An empty string is provided in s3_wal_path of the standby cluster will result in error and no statefulset will be created. +- Only one pod can be deployed for stand-by cluster. - To manually promote the standby_cluster, use patronictl and remove config entry. - There is no way to transform a non-standby cluster to standby cluster through operator. Hence, if a cluster is created without standby section in YAML and later modified by adding that section, there will be no effect on the cluster. However, it can be done through Patroni by adding the standby_cluster section using patronictl edit-config. Note that the transformed standby cluster will not be doing any streaming, rather will just be in standby mode and allow read-only transactions only. diff --git a/manifests/complete-postgres-manifest.yaml b/manifests/complete-postgres-manifest.yaml index 2a78f4aad..cd670f009 100644 --- a/manifests/complete-postgres-manifest.yaml +++ b/manifests/complete-postgres-manifest.yaml @@ -66,7 +66,7 @@ spec: # cluster: "acid-batman" # timestamp: "2017-12-19T12:40:33+01:00" # timezone required (offset relative to UTC, see RFC 3339 section 5.6) # s3_wal_path: "s3://custom/path/to/bucket" - # Make this a standby cluster and provide the s3 bucket path of source cluster for continuous streaming. + # Make this a standby cluster and provide the s3 bucket path of source cluster for continuous streaming. Also change the above mentioned numberOfInstances to 1 for this cluster. # standby: # s3_wal_path: "s3://path/to/bucket/containing/wal/of/source/cluster/" diff --git a/pkg/cluster/k8sres.go b/pkg/cluster/k8sres.go index 9b30452df..cadc662f4 100644 --- a/pkg/cluster/k8sres.go +++ b/pkg/cluster/k8sres.go @@ -977,6 +977,11 @@ func (c *Cluster) getNumberOfInstances(spec *acidv1.PostgresSpec) int32 { cur := spec.NumberOfInstances newcur := cur + /* Limit the max number of pods to one, if this is standby-cluster */ + if spec.StandbyCluster != nil { + c.logger.Infof("Standby cluster can have maximum of 1 pod") + max = 1 + } if max >= 0 && newcur > max { newcur = max } @@ -1285,12 +1290,9 @@ func (c *Cluster) generateStandbyEnvironment(description *acidv1.StandbyDescript return nil } // standby with S3, find out the bucket to setup standby - msg := "Standby from S3 bucket" + msg := "Standby from S3 bucket using custom parsed S3WalPath %s from the manifest" c.logger.Info(msg, description.S3WalPath) - msg = "Use custom parsed S3WalPath %s from the manifest" - c.logger.Warningf(msg, description.S3WalPath) - result = append(result, v1.EnvVar{ Name: "STANDBY_WALE_S3_PREFIX", Value: description.S3WalPath,