@@ -366,6 +366,12 @@ func (c *Cluster) Create() (err error) {
366366 c .logger .Info ("a monitoring secret was successfully created" )
367367 }
368368
369+ if specHasPgbackrestClone (& c .Postgresql .Spec ) {
370+ if err := c .createPgbackrestCloneConfig (); err != nil {
371+ return fmt .Errorf ("could not create pgbackrest clone config: %v" , err )
372+ }
373+ }
374+
369375 if c .multisiteEnabled () {
370376 c .logger .Infof ("waiting for load balancer IP to be assigned" )
371377 c .waitForPrimaryLoadBalancerIp ()
@@ -1067,6 +1073,28 @@ func (c *Cluster) Update(oldSpec, newSpec *cpov1.Postgresql) error {
10671073 }
10681074 }()
10691075
1076+ // Clone configmap for pgbackrest
1077+ func () {
1078+ if specHasPgbackrestClone (& oldSpec .Spec ) {
1079+ if specHasPgbackrestClone (& newSpec .Spec ) {
1080+ // TODO: if we know cluster state and it has been initialized, then should ignore this
1081+ if err := c .updatePgbackrestCloneConfig (); err != nil {
1082+ c .logger .Warningf ("could not update pgbackrest clone config: %v" , err )
1083+ updateFailed = true
1084+ }
1085+ } else {
1086+ if err := c .deletePgbackrestCloneConfig (); err != nil {
1087+ c .logger .Warningf ("could not delete pgbackrest clone config: %v" , err )
1088+ }
1089+ }
1090+ } else if specHasPgbackrestClone (& newSpec .Spec ) {
1091+ c .logger .Warningf ("Can't add a clone specification after cluster has been initialized" )
1092+ updateFailed = true
1093+ } else {
1094+ // TODO: try to delete just in case?
1095+ }
1096+ }()
1097+
10701098 // Statefulset
10711099 func () {
10721100 oldSs , err := c .generateStatefulSet (& oldSpec .Spec )
@@ -1225,6 +1253,10 @@ func specHasPgbackrestPVCRepo(newSpec *cpov1.PostgresSpec) bool {
12251253 return false
12261254}
12271255
1256+ func specHasPgbackrestClone (newSpec * cpov1.PostgresSpec ) bool {
1257+ return newSpec .Clone != nil && newSpec .Clone .Pgbackrest != nil
1258+ }
1259+
12281260func syncResources (a , b * v1.ResourceRequirements ) bool {
12291261 for _ , res := range []v1.ResourceName {
12301262 v1 .ResourceCPU ,
@@ -1291,6 +1323,10 @@ func (c *Cluster) Delete() {
12911323 c .logger .Warningf ("could not delete pod disruption budget: %v" , err )
12921324 }
12931325
1326+ if err := c .deletePgbackrestCloneConfig (); err != nil {
1327+ c .logger .Warningf ("could not delete pgbackrest clone config: %v" , err )
1328+ }
1329+
12941330 for _ , role := range []PostgresRole {Master , Replica , ClusterPods } {
12951331
12961332 if ! c .patroniKubernetesUseConfigMaps () {
0 commit comments