@@ -51,6 +51,7 @@ func newFakeK8sAnnotationsClient() (k8sutil.KubernetesClient, *k8sFake.Clientset
51
51
EndpointsGetter : clientSet .CoreV1 (),
52
52
PodsGetter : clientSet .CoreV1 (),
53
53
DeploymentsGetter : clientSet .AppsV1 (),
54
+ CronJobsGetter : clientSet .BatchV1 (),
54
55
}, clientSet
55
56
}
56
57
@@ -176,6 +177,22 @@ func checkResourcesInheritedAnnotations(cluster *Cluster, resultAnnotations map[
176
177
return nil
177
178
}
178
179
180
+ checkCronJob := func (annotations map [string ]string ) error {
181
+ cronJobList , err := cluster .KubeClient .CronJobs (namespace ).List (context .TODO (), clusterOptions )
182
+ if err != nil {
183
+ return err
184
+ }
185
+ for _ , cronJob := range cronJobList .Items {
186
+ if err := containsAnnotations (updateAnnotations (annotations ), cronJob .Annotations , cronJob .ObjectMeta .Name , "Logical backup cron job" ); err != nil {
187
+ return err
188
+ }
189
+ if err := containsAnnotations (updateAnnotations (annotations ), cronJob .Spec .JobTemplate .Spec .Template .Annotations , cronJob .Name , "Logical backup cron job pod template" ); err != nil {
190
+ return err
191
+ }
192
+ }
193
+ return nil
194
+ }
195
+
179
196
checkSecrets := func (annotations map [string ]string ) error {
180
197
secretList , err := cluster .KubeClient .Secrets (namespace ).List (context .TODO (), clusterOptions )
181
198
if err != nil {
@@ -203,7 +220,7 @@ func checkResourcesInheritedAnnotations(cluster *Cluster, resultAnnotations map[
203
220
}
204
221
205
222
checkFuncs := []func (map [string ]string ) error {
206
- checkSts , checkPods , checkSvc , checkPdb , checkPooler , checkPvc , checkSecrets , checkEndpoints ,
223
+ checkSts , checkPods , checkSvc , checkPdb , checkPooler , checkCronJob , checkPvc , checkSecrets , checkEndpoints ,
207
224
}
208
225
for _ , f := range checkFuncs {
209
226
if err := f (resultAnnotations ); err != nil {
@@ -251,6 +268,7 @@ func newInheritedAnnotationsCluster(client k8sutil.KubernetesClient) (*Cluster,
251
268
Spec : acidv1.PostgresSpec {
252
269
EnableConnectionPooler : boolToPointer (true ),
253
270
EnableReplicaConnectionPooler : boolToPointer (true ),
271
+ EnableLogicalBackup : true ,
254
272
Volume : acidv1.Volume {
255
273
Size : "1Gi" ,
256
274
},
@@ -306,6 +324,10 @@ func newInheritedAnnotationsCluster(client k8sutil.KubernetesClient) (*Cluster,
306
324
if err != nil {
307
325
return nil , err
308
326
}
327
+ err = cluster .createLogicalBackupJob ()
328
+ if err != nil {
329
+ return nil , err
330
+ }
309
331
pvcList := CreatePVCs (namespace , clusterName , cluster .labelsSet (false ), 2 , "1Gi" )
310
332
for _ , pvc := range pvcList .Items {
311
333
_ , err = cluster .KubeClient .PersistentVolumeClaims (namespace ).Create (context .TODO (), & pvc , metav1.CreateOptions {})
0 commit comments