) = + conditions.all { it.isMet(dependentResource, primary, context) } +} diff --git a/operator/src/main/kotlin/eu/glasskube/operator/generic/dependent/postgres/DependentPostgresCluster.kt b/operator/src/main/kotlin/eu/glasskube/operator/generic/dependent/postgres/DependentPostgresCluster.kt index 3c1d6f0d..53dd95d5 100644 --- a/operator/src/main/kotlin/eu/glasskube/operator/generic/dependent/postgres/DependentPostgresCluster.kt +++ b/operator/src/main/kotlin/eu/glasskube/operator/generic/dependent/postgres/DependentPostgresCluster.kt @@ -76,7 +76,11 @@ abstract class DependentPostgresCluster
( storageClass = primary.getSpec().database.storage?.storageClass ?: primary.defaultStorageClass, size = primary.getSpec().database.storage?.size ?: primary.defaultStorageSize ), - backup = backupConfigurationProvider.getBackupConfiguration(primary, context), + backup = if (primary.getSpec().database.backups?.enabled != false) { + backupConfigurationProvider.getBackupConfiguration(primary, context) + } else { + null + }, monitoring = MonitoringConfiguration(enablePodMonitor = true), resources = primary.databaseResources ) diff --git a/operator/src/main/kotlin/eu/glasskube/operator/generic/dependent/postgres/DependentPostgresScheduledBackup.kt b/operator/src/main/kotlin/eu/glasskube/operator/generic/dependent/postgres/DependentPostgresScheduledBackup.kt index 672821f2..90db1474 100644 --- a/operator/src/main/kotlin/eu/glasskube/operator/generic/dependent/postgres/DependentPostgresScheduledBackup.kt +++ b/operator/src/main/kotlin/eu/glasskube/operator/generic/dependent/postgres/DependentPostgresScheduledBackup.kt @@ -17,6 +17,9 @@ abstract class DependentPostgresScheduledBackup
( ) : PostgresDependentResource
, CRUDKubernetesDependentResource : PostgresWithBackupsEnabledCondition ) =
+ primary.getSpec().database.backups?.enabled != false
+}
diff --git a/operator/src/main/kotlin/eu/glasskube/operator/generic/dependent/postgres/PostgresWithoutBackupsSpecCondition.kt b/operator/src/main/kotlin/eu/glasskube/operator/generic/dependent/postgres/PostgresWithoutS3BackupsSpecCondition.kt
similarity index 83%
rename from operator/src/main/kotlin/eu/glasskube/operator/generic/dependent/postgres/PostgresWithoutBackupsSpecCondition.kt
rename to operator/src/main/kotlin/eu/glasskube/operator/generic/dependent/postgres/PostgresWithoutS3BackupsSpecCondition.kt
index d6963c21..69354b13 100644
--- a/operator/src/main/kotlin/eu/glasskube/operator/generic/dependent/postgres/PostgresWithoutBackupsSpecCondition.kt
+++ b/operator/src/main/kotlin/eu/glasskube/operator/generic/dependent/postgres/PostgresWithoutS3BackupsSpecCondition.kt
@@ -7,9 +7,9 @@ import io.javaoperatorsdk.operator.api.reconciler.Context
import io.javaoperatorsdk.operator.api.reconciler.dependent.DependentResource
import io.javaoperatorsdk.operator.processing.dependent.workflow.Condition
-abstract class PostgresWithoutBackupsSpecCondition ) =
- primary.getSpec().database.backups == null
+ primary.getSpec().database.backups?.s3 == null
}
diff --git a/operator/src/main/kotlin/eu/glasskube/operator/generic/dependent/postgres/backup/BackupSpecBackupConfigurationProvider.kt b/operator/src/main/kotlin/eu/glasskube/operator/generic/dependent/postgres/backup/BackupSpecBackupConfigurationProvider.kt
index a6753409..c6474a19 100644
--- a/operator/src/main/kotlin/eu/glasskube/operator/generic/dependent/postgres/backup/BackupSpecBackupConfigurationProvider.kt
+++ b/operator/src/main/kotlin/eu/glasskube/operator/generic/dependent/postgres/backup/BackupSpecBackupConfigurationProvider.kt
@@ -17,26 +17,28 @@ open class BackupSpecBackupConfigurationProvider (
where P : HasMetadata, P : ResourceWithDatabaseSpec ) =
- primary.getSpec().database.backups?.let { spec ->
- BackupConfiguration(
- BarmanObjectStoreConfiguration(
- endpointURL = spec.s3.endpoint?.let {
- when {
- "://" in it -> it
- else -> "https://$it"
- }
- },
- destinationPath = "s3://${spec.s3.bucket}",
- s3Credentials = S3Credentials(
- spec.s3.accessKeySecret,
- spec.s3.secretKeySecret,
- spec.s3.regionSecret
+ primary.getSpec().database.backups?.run {
+ s3?.let { s3Spec ->
+ BackupConfiguration(
+ BarmanObjectStoreConfiguration(
+ endpointURL = s3Spec.endpoint?.let {
+ when {
+ "://" in it -> it
+ else -> "https://$it"
+ }
+ },
+ destinationPath = "s3://${s3Spec.bucket}",
+ s3Credentials = S3Credentials(
+ s3Spec.accessKeySecret,
+ s3Spec.secretKeySecret,
+ s3Spec.regionSecret
+ ),
+ wal = WalBackupConfiguration(CompressionType.GZIP),
+ data = DataBackupConfiguration(CompressionType.GZIP)
),
- wal = WalBackupConfiguration(CompressionType.GZIP),
- data = DataBackupConfiguration(CompressionType.GZIP)
- ),
- retentionPolicy = spec.retentionPolicy
- ?: defaultRetentionPolicyProvider.run { primary.getDefaultRetentionPolicy() }
- )
+ retentionPolicy = retentionPolicy
+ ?: defaultRetentionPolicyProvider.run { primary.getDefaultRetentionPolicy() }
+ )
+ }
}
}
diff --git a/operator/src/main/kotlin/eu/glasskube/operator/generic/dependent/postgres/backup/PostgresMinioBucketPrecondition.kt b/operator/src/main/kotlin/eu/glasskube/operator/generic/dependent/postgres/backup/PostgresMinioBucketPrecondition.kt
new file mode 100644
index 00000000..a4a53ab6
--- /dev/null
+++ b/operator/src/main/kotlin/eu/glasskube/operator/generic/dependent/postgres/backup/PostgresMinioBucketPrecondition.kt
@@ -0,0 +1,13 @@
+package eu.glasskube.operator.generic.dependent.postgres.backup
+
+import eu.glasskube.operator.apps.common.database.ResourceWithDatabaseSpec
+import eu.glasskube.operator.apps.common.database.postgres.PostgresDatabaseSpec
+import eu.glasskube.operator.generic.condition.AllCompositeCondition
+import eu.glasskube.operator.generic.dependent.postgres.PostgresWithBackupsEnabledCondition
+import eu.glasskube.operator.generic.dependent.postgres.PostgresWithoutS3BackupsSpecCondition
+import io.fabric8.kubernetes.api.model.HasMetadata
+
+abstract class PostgresMinioBucketPrecondition