From 742a43a879c9832b4f0617ff90e843e434152c9f Mon Sep 17 00:00:00 2001 From: Rafia Sabih Date: Fri, 7 Jun 2019 12:09:08 +0200 Subject: [PATCH] Adding docs and tests --- docs/user.md | 12 ++++++++++++ manifests/complete-postgres-manifest.yaml | 5 +++++ pkg/apis/acid.zalan.do/v1/util_test.go | 22 ++++++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/docs/user.md b/docs/user.md index bab09f8c9..dfd0a8f44 100644 --- a/docs/user.md +++ b/docs/user.md @@ -254,6 +254,18 @@ metadata: Note that timezone is required for `timestamp`. Otherwise, offset is relative to UTC, see [RFC 3339 section 5.6) 3339 section 5.6](https://www.ietf.org/rfc/rfc3339.txt). +## Setting up a standby cluster + +Standby clusters are like normal cluster but they are streaming from a remote master. Patroni supports it, [read this](https://github.com/zalando/patroni/blob/bd2c54581abb42a7d3a3da551edf0b8732eefd27/docs/replica_bootstrap.rst#standby-cluster) to know more about them. Currently operator supports setting up standby only through an S3 bucket. For this you need to add a section standby in the YAML file as follows. + +```yaml +spec: + standby: + uid: "UID of the master cluster" + cluster: "Name of the master cluster" + s3_wal_path: "s3 bucket path to the master" +``` + ## Sidecar Support Each cluster can specify arbitrary sidecars to run. These containers could be used for diff --git a/manifests/complete-postgres-manifest.yaml b/manifests/complete-postgres-manifest.yaml index 276e07a1f..f3e26223e 100644 --- a/manifests/complete-postgres-manifest.yaml +++ b/manifests/complete-postgres-manifest.yaml @@ -64,6 +64,11 @@ 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 mention the information of source cluster from where to do continuous streaming. + # standby: + # uid: "uid of the master" + # cluster: "team-standby" + # s3_wal_path: "s3://custom/path/to/bucket" maintenanceWindows: - 01:00-06:00 #UTC - Sat:00:00-04:00 diff --git a/pkg/apis/acid.zalan.do/v1/util_test.go b/pkg/apis/acid.zalan.do/v1/util_test.go index f34c285d9..5b337ded6 100644 --- a/pkg/apis/acid.zalan.do/v1/util_test.go +++ b/pkg/apis/acid.zalan.do/v1/util_test.go @@ -352,6 +352,28 @@ var unmarshalCluster = []struct { }, marshal: []byte(`{"kind":"Postgresql","apiVersion":"acid.zalan.do/v1","metadata":{"name":"acid-testcluster1","creationTimestamp":null},"spec":{"postgresql":{"version":"","parameters":null},"volume":{"size":"","storageClass":""},"patroni":{"initdb":null,"pg_hba":null,"ttl":0,"loop_wait":0,"retry_timeout":0,"maximum_lag_on_failover":0,"slots":null},"resources":{"requests":{"cpu":"","memory":""},"limits":{"cpu":"","memory":""}},"teamId":"acid","allowedSourceRanges":null,"numberOfInstances":0,"users":null,"clone":{"cluster":"team-batman"}},"status":{"PostgresClusterStatus":""}}`), err: nil}, + // standby example + { + in: []byte(`{"kind": "Postgresql","apiVersion": "acid.zalan.do/v1","metadata": {"name": "acid-testcluster1"}, "spec": {"teamId": "acid", "standby": {"cluster": "team-batman"}}}`), + out: Postgresql{ + TypeMeta: metav1.TypeMeta{ + Kind: "Postgresql", + APIVersion: "acid.zalan.do/v1", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "acid-testcluster1", + }, + Spec: PostgresSpec{ + TeamID: "acid", + StandbyCluster: StandbyDescription{ + ClusterName: "team-batman", + }, + ClusterName: "testcluster1", + }, + Error: "", + }, + marshal: []byte(`{"kind":"Postgresql","apiVersion":"acid.zalan.do/v1","metadata":{"name":"acid-testcluster1","creationTimestamp":null},"spec":{"postgresql":{"version":"","parameters":null},"volume":{"size":"","storageClass":""},"patroni":{"initdb":null,"pg_hba":null,"ttl":0,"loop_wait":0,"retry_timeout":0,"maximum_lag_on_failover":0,"slots":null},"resources":{"requests":{"cpu":"","memory":""},"limits":{"cpu":"","memory":""}},"teamId":"acid","allowedSourceRanges":null,"numberOfInstances":0,"users":null,"standby":{"cluster":"team-batman"}},"status":{"PostgresClusterStatus":""}}`), + err: nil}, // erroneous examples { in: []byte(`{"kind": "Postgresql","apiVersion": "acid.zalan.do/v1"`),