diff --git a/.idea/misc.xml b/.idea/misc.xml index 8883d1e6..bb0fefc3 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,12 +1,13 @@ + - + - \ No newline at end of file + diff --git a/deploy/crd/giteas.glasskube.eu-v1.yml b/deploy/crd/giteas.glasskube.eu-v1.yml index 9b52c135..5a2051b7 100644 --- a/deploy/crd/giteas.glasskube.eu-v1.yml +++ b/deploy/crd/giteas.glasskube.eu-v1.yml @@ -91,6 +91,8 @@ spec: type: integer backups: properties: + enabled: + type: boolean schedule: type: string retentionPolicy: @@ -133,8 +135,6 @@ spec: - accessKeySecret - secretKeySecret type: object - required: - - s3 type: object storage: properties: diff --git a/deploy/crd/gitlabs.glasskube.eu-v1.yml b/deploy/crd/gitlabs.glasskube.eu-v1.yml index d464d694..213dd37a 100644 --- a/deploy/crd/gitlabs.glasskube.eu-v1.yml +++ b/deploy/crd/gitlabs.glasskube.eu-v1.yml @@ -153,6 +153,8 @@ spec: type: integer backups: properties: + enabled: + type: boolean schedule: type: string retentionPolicy: @@ -195,8 +197,6 @@ spec: - accessKeySecret - secretKeySecret type: object - required: - - s3 type: object storage: properties: diff --git a/deploy/crd/glitchtips.glasskube.eu-v1.yml b/deploy/crd/glitchtips.glasskube.eu-v1.yml index d521f2c4..9391bf9c 100644 --- a/deploy/crd/glitchtips.glasskube.eu-v1.yml +++ b/deploy/crd/glitchtips.glasskube.eu-v1.yml @@ -81,6 +81,8 @@ spec: type: integer backups: properties: + enabled: + type: boolean schedule: type: string retentionPolicy: @@ -123,8 +125,6 @@ spec: - accessKeySecret - secretKeySecret type: object - required: - - s3 type: object storage: properties: diff --git a/deploy/crd/keycloaks.glasskube.eu-v1.yml b/deploy/crd/keycloaks.glasskube.eu-v1.yml index 9ca0d7aa..ae52570a 100644 --- a/deploy/crd/keycloaks.glasskube.eu-v1.yml +++ b/deploy/crd/keycloaks.glasskube.eu-v1.yml @@ -59,6 +59,8 @@ spec: type: integer backups: properties: + enabled: + type: boolean schedule: type: string retentionPolicy: @@ -101,8 +103,6 @@ spec: - accessKeySecret - secretKeySecret type: object - required: - - s3 type: object storage: properties: diff --git a/deploy/crd/metabases.glasskube.eu-v1.yml b/deploy/crd/metabases.glasskube.eu-v1.yml index 8a36a96f..fde2a144 100644 --- a/deploy/crd/metabases.glasskube.eu-v1.yml +++ b/deploy/crd/metabases.glasskube.eu-v1.yml @@ -77,6 +77,8 @@ spec: type: integer backups: properties: + enabled: + type: boolean schedule: type: string retentionPolicy: @@ -119,8 +121,6 @@ spec: - accessKeySecret - secretKeySecret type: object - required: - - s3 type: object storage: properties: diff --git a/deploy/crd/nextclouds.glasskube.eu-v1.yml b/deploy/crd/nextclouds.glasskube.eu-v1.yml index 0951bee2..fc5a4bce 100644 --- a/deploy/crd/nextclouds.glasskube.eu-v1.yml +++ b/deploy/crd/nextclouds.glasskube.eu-v1.yml @@ -170,6 +170,8 @@ spec: type: integer backups: properties: + enabled: + type: boolean schedule: type: string retentionPolicy: @@ -212,8 +214,6 @@ spec: - accessKeySecret - secretKeySecret type: object - required: - - s3 type: object storage: properties: diff --git a/deploy/crd/odoos.glasskube.eu-v1.yml b/deploy/crd/odoos.glasskube.eu-v1.yml index c05e3428..3c43758b 100644 --- a/deploy/crd/odoos.glasskube.eu-v1.yml +++ b/deploy/crd/odoos.glasskube.eu-v1.yml @@ -56,6 +56,8 @@ spec: type: integer backups: properties: + enabled: + type: boolean schedule: type: string retentionPolicy: @@ -98,8 +100,6 @@ spec: - accessKeySecret - secretKeySecret type: object - required: - - s3 type: object storage: properties: diff --git a/deploy/crd/planes.glasskube.eu-v1.yml b/deploy/crd/planes.glasskube.eu-v1.yml index 79b38dbb..0f3039bf 100644 --- a/deploy/crd/planes.glasskube.eu-v1.yml +++ b/deploy/crd/planes.glasskube.eu-v1.yml @@ -243,6 +243,8 @@ spec: type: integer backups: properties: + enabled: + type: boolean schedule: type: string retentionPolicy: @@ -285,8 +287,6 @@ spec: - accessKeySecret - secretKeySecret type: object - required: - - s3 type: object storage: properties: diff --git a/deploy/crd/vaults.glasskube.eu-v1.yml b/deploy/crd/vaults.glasskube.eu-v1.yml index 3bc87743..9cadba37 100644 --- a/deploy/crd/vaults.glasskube.eu-v1.yml +++ b/deploy/crd/vaults.glasskube.eu-v1.yml @@ -113,6 +113,8 @@ spec: type: integer backups: properties: + enabled: + type: boolean schedule: type: string retentionPolicy: @@ -155,8 +157,6 @@ spec: - accessKeySecret - secretKeySecret type: object - required: - - s3 type: object storage: properties: diff --git a/operator/src/main/kotlin/eu/glasskube/operator/apps/common/database/postgres/PostgresBackupsSpec.kt b/operator/src/main/kotlin/eu/glasskube/operator/apps/common/database/postgres/PostgresBackupsSpec.kt index 13701dcd..8f629177 100644 --- a/operator/src/main/kotlin/eu/glasskube/operator/apps/common/database/postgres/PostgresBackupsSpec.kt +++ b/operator/src/main/kotlin/eu/glasskube/operator/apps/common/database/postgres/PostgresBackupsSpec.kt @@ -5,10 +5,10 @@ import io.fabric8.generator.annotation.Required import io.fabric8.kubernetes.api.model.SecretKeySelector data class PostgresBackupsSpec( + val enabled: Boolean = true, val schedule: String?, val retentionPolicy: String?, - @field:Required - val s3: S3Spec + val s3: S3Spec? ) : BackupsSpec { data class S3Spec( val endpoint: String?, diff --git a/operator/src/main/kotlin/eu/glasskube/operator/apps/gitea/GiteaReconciler.kt b/operator/src/main/kotlin/eu/glasskube/operator/apps/gitea/GiteaReconciler.kt index f8d83dcf..0126dd92 100644 --- a/operator/src/main/kotlin/eu/glasskube/operator/apps/gitea/GiteaReconciler.kt +++ b/operator/src/main/kotlin/eu/glasskube/operator/apps/gitea/GiteaReconciler.kt @@ -49,7 +49,8 @@ import io.javaoperatorsdk.operator.api.reconciler.dependent.Dependent Dependent( type = GiteaPostgresBackup::class, name = "GiteaPostgresBackup", - dependsOn = ["GiteaPostgresCluster"] + dependsOn = ["GiteaPostgresCluster"], + reconcilePrecondition = GiteaPostgresBackup.ReconcilePrecondition::class ), Dependent( type = GiteaConfigMap::class, diff --git a/operator/src/main/kotlin/eu/glasskube/operator/apps/gitea/dependent/GiteaMinioBucket.kt b/operator/src/main/kotlin/eu/glasskube/operator/apps/gitea/dependent/GiteaMinioBucket.kt index 3190f518..c7d64840 100644 --- a/operator/src/main/kotlin/eu/glasskube/operator/apps/gitea/dependent/GiteaMinioBucket.kt +++ b/operator/src/main/kotlin/eu/glasskube/operator/apps/gitea/dependent/GiteaMinioBucket.kt @@ -5,7 +5,7 @@ import eu.glasskube.operator.apps.gitea.Gitea import eu.glasskube.operator.apps.gitea.GiteaReconciler import eu.glasskube.operator.apps.gitea.genericResourceName import eu.glasskube.operator.apps.gitea.resourceLabels -import eu.glasskube.operator.generic.dependent.postgres.PostgresWithoutBackupsSpecCondition +import eu.glasskube.operator.generic.dependent.postgres.backup.PostgresMinioBucketPrecondition import eu.glasskube.operator.infra.minio.MinioBucket import eu.glasskube.operator.infra.minio.MinioBucketSpec import eu.glasskube.operator.infra.minio.minioBucket @@ -15,7 +15,7 @@ import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDep @KubernetesDependent(labelSelector = GiteaReconciler.SELECTOR) class GiteaMinioBucket : CRUDKubernetesDependentResource(MinioBucket::class.java) { - internal class ReconcilePrecondition : PostgresWithoutBackupsSpecCondition() + internal class ReconcilePrecondition : PostgresMinioBucketPrecondition() override fun desired(primary: Gitea, context: Context) = minioBucket { metadata { diff --git a/operator/src/main/kotlin/eu/glasskube/operator/apps/gitea/dependent/GiteaPostgresBackup.kt b/operator/src/main/kotlin/eu/glasskube/operator/apps/gitea/dependent/GiteaPostgresBackup.kt index 6a19f750..ba6ad208 100644 --- a/operator/src/main/kotlin/eu/glasskube/operator/apps/gitea/dependent/GiteaPostgresBackup.kt +++ b/operator/src/main/kotlin/eu/glasskube/operator/apps/gitea/dependent/GiteaPostgresBackup.kt @@ -6,4 +6,6 @@ import eu.glasskube.operator.generic.dependent.postgres.DependentPostgresSchedul import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDependent @KubernetesDependent(labelSelector = GiteaReconciler.SELECTOR) -class GiteaPostgresBackup : DependentPostgresScheduledBackup(Gitea.Postgres) +class GiteaPostgresBackup : DependentPostgresScheduledBackup(Gitea.Postgres) { + class ReconcilePrecondition : DependentPostgresScheduledBackup.ReconcilePrecondition() +} diff --git a/operator/src/main/kotlin/eu/glasskube/operator/apps/gitlab/GitlabReconciler.kt b/operator/src/main/kotlin/eu/glasskube/operator/apps/gitlab/GitlabReconciler.kt index 82353e0e..9c54253c 100644 --- a/operator/src/main/kotlin/eu/glasskube/operator/apps/gitlab/GitlabReconciler.kt +++ b/operator/src/main/kotlin/eu/glasskube/operator/apps/gitlab/GitlabReconciler.kt @@ -47,7 +47,8 @@ import io.javaoperatorsdk.operator.api.reconciler.dependent.Dependent Dependent( type = GitlabPostgresBackup::class, name = "GitlabPostgresBackup", - dependsOn = ["GitlabPostgresCluster"] + dependsOn = ["GitlabPostgresCluster"], + reconcilePrecondition = GitlabPostgresBackup.ReconcilePrecondition::class ), Dependent( type = GitlabDeployment::class, diff --git a/operator/src/main/kotlin/eu/glasskube/operator/apps/gitlab/dependent/GitlabMinioBucket.kt b/operator/src/main/kotlin/eu/glasskube/operator/apps/gitlab/dependent/GitlabMinioBucket.kt index 6e5304cb..6aec12ea 100644 --- a/operator/src/main/kotlin/eu/glasskube/operator/apps/gitlab/dependent/GitlabMinioBucket.kt +++ b/operator/src/main/kotlin/eu/glasskube/operator/apps/gitlab/dependent/GitlabMinioBucket.kt @@ -5,7 +5,7 @@ import eu.glasskube.operator.apps.gitlab.Gitlab import eu.glasskube.operator.apps.gitlab.GitlabReconciler import eu.glasskube.operator.apps.gitlab.genericResourceName import eu.glasskube.operator.apps.gitlab.resourceLabels -import eu.glasskube.operator.generic.dependent.postgres.PostgresWithoutBackupsSpecCondition +import eu.glasskube.operator.generic.dependent.postgres.backup.PostgresMinioBucketPrecondition import eu.glasskube.operator.infra.minio.MinioBucket import eu.glasskube.operator.infra.minio.MinioBucketSpec import eu.glasskube.operator.infra.minio.minioBucket @@ -15,7 +15,7 @@ import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDep @KubernetesDependent(labelSelector = GitlabReconciler.SELECTOR) class GitlabMinioBucket : CRUDKubernetesDependentResource(MinioBucket::class.java) { - internal class ReconcilePrecondition : PostgresWithoutBackupsSpecCondition() + internal class ReconcilePrecondition : PostgresMinioBucketPrecondition() override fun desired(primary: Gitlab, context: Context) = minioBucket { metadata { diff --git a/operator/src/main/kotlin/eu/glasskube/operator/apps/gitlab/dependent/GitlabPostgresBackup.kt b/operator/src/main/kotlin/eu/glasskube/operator/apps/gitlab/dependent/GitlabPostgresBackup.kt index 6a264191..7185d1b5 100644 --- a/operator/src/main/kotlin/eu/glasskube/operator/apps/gitlab/dependent/GitlabPostgresBackup.kt +++ b/operator/src/main/kotlin/eu/glasskube/operator/apps/gitlab/dependent/GitlabPostgresBackup.kt @@ -6,4 +6,6 @@ import eu.glasskube.operator.generic.dependent.postgres.DependentPostgresSchedul import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDependent @KubernetesDependent(labelSelector = GitlabReconciler.SELECTOR) -class GitlabPostgresBackup : DependentPostgresScheduledBackup(Gitlab.Postgres) +class GitlabPostgresBackup : DependentPostgresScheduledBackup(Gitlab.Postgres) { + class ReconcilePrecondition : DependentPostgresScheduledBackup.ReconcilePrecondition() +} diff --git a/operator/src/main/kotlin/eu/glasskube/operator/apps/glitchtip/GlitchtipReconciler.kt b/operator/src/main/kotlin/eu/glasskube/operator/apps/glitchtip/GlitchtipReconciler.kt index 1154a5a8..6691175f 100644 --- a/operator/src/main/kotlin/eu/glasskube/operator/apps/glitchtip/GlitchtipReconciler.kt +++ b/operator/src/main/kotlin/eu/glasskube/operator/apps/glitchtip/GlitchtipReconciler.kt @@ -48,7 +48,8 @@ import kotlin.jvm.optionals.getOrDefault Dependent( type = GlitchtipPostgresBackup::class, name = "GlitchtipPostgresBackup", - dependsOn = ["GlitchtipPostgresCluster"] + dependsOn = ["GlitchtipPostgresCluster"], + reconcilePrecondition = GlitchtipPostgresBackup.ReconcilePrecondition::class ), Dependent( type = GlitchtipConfigMap::class, diff --git a/operator/src/main/kotlin/eu/glasskube/operator/apps/glitchtip/dependent/GlitchtipMinioBucket.kt b/operator/src/main/kotlin/eu/glasskube/operator/apps/glitchtip/dependent/GlitchtipMinioBucket.kt index d73eed66..3aa10b31 100644 --- a/operator/src/main/kotlin/eu/glasskube/operator/apps/glitchtip/dependent/GlitchtipMinioBucket.kt +++ b/operator/src/main/kotlin/eu/glasskube/operator/apps/glitchtip/dependent/GlitchtipMinioBucket.kt @@ -5,7 +5,7 @@ import eu.glasskube.operator.apps.glitchtip.Glitchtip import eu.glasskube.operator.apps.glitchtip.GlitchtipReconciler import eu.glasskube.operator.apps.glitchtip.genericResourceName import eu.glasskube.operator.apps.glitchtip.resourceLabels -import eu.glasskube.operator.generic.dependent.postgres.PostgresWithoutBackupsSpecCondition +import eu.glasskube.operator.generic.dependent.postgres.backup.PostgresMinioBucketPrecondition import eu.glasskube.operator.infra.minio.MinioBucket import eu.glasskube.operator.infra.minio.MinioBucketSpec import eu.glasskube.operator.infra.minio.minioBucket @@ -15,7 +15,7 @@ import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDep @KubernetesDependent(labelSelector = GlitchtipReconciler.SELECTOR) class GlitchtipMinioBucket : CRUDKubernetesDependentResource(MinioBucket::class.java) { - internal class ReconcilePrecondition : PostgresWithoutBackupsSpecCondition() + internal class ReconcilePrecondition : PostgresMinioBucketPrecondition() override fun desired(primary: Glitchtip, context: Context) = minioBucket { metadata { diff --git a/operator/src/main/kotlin/eu/glasskube/operator/apps/glitchtip/dependent/GlitchtipPostgresBackup.kt b/operator/src/main/kotlin/eu/glasskube/operator/apps/glitchtip/dependent/GlitchtipPostgresBackup.kt index 3b774bf3..1caac204 100644 --- a/operator/src/main/kotlin/eu/glasskube/operator/apps/glitchtip/dependent/GlitchtipPostgresBackup.kt +++ b/operator/src/main/kotlin/eu/glasskube/operator/apps/glitchtip/dependent/GlitchtipPostgresBackup.kt @@ -6,4 +6,6 @@ import eu.glasskube.operator.generic.dependent.postgres.DependentPostgresSchedul import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDependent @KubernetesDependent(labelSelector = GlitchtipReconciler.SELECTOR) -class GlitchtipPostgresBackup : DependentPostgresScheduledBackup(Glitchtip.Postgres) +class GlitchtipPostgresBackup : DependentPostgresScheduledBackup(Glitchtip.Postgres) { + class ReconcilePrecondition : DependentPostgresScheduledBackup.ReconcilePrecondition() +} diff --git a/operator/src/main/kotlin/eu/glasskube/operator/apps/keycloak/KeycloakReconciler.kt b/operator/src/main/kotlin/eu/glasskube/operator/apps/keycloak/KeycloakReconciler.kt index 339aecc2..c2cc2d4b 100644 --- a/operator/src/main/kotlin/eu/glasskube/operator/apps/keycloak/KeycloakReconciler.kt +++ b/operator/src/main/kotlin/eu/glasskube/operator/apps/keycloak/KeycloakReconciler.kt @@ -39,7 +39,8 @@ import kotlin.jvm.optionals.getOrDefault Dependent( type = KeycloakPostgresBackup::class, name = "KeycloakPostgresBackup", - dependsOn = ["KeycloakPostgresCluster"] + dependsOn = ["KeycloakPostgresCluster"], + reconcilePrecondition = KeycloakPostgresBackup.ReconcilePrecondition::class ), Dependent( type = KeycloakDeployment::class, diff --git a/operator/src/main/kotlin/eu/glasskube/operator/apps/keycloak/dependent/KeycloakPostgresBackup.kt b/operator/src/main/kotlin/eu/glasskube/operator/apps/keycloak/dependent/KeycloakPostgresBackup.kt index 78691bcd..ea78adee 100644 --- a/operator/src/main/kotlin/eu/glasskube/operator/apps/keycloak/dependent/KeycloakPostgresBackup.kt +++ b/operator/src/main/kotlin/eu/glasskube/operator/apps/keycloak/dependent/KeycloakPostgresBackup.kt @@ -6,4 +6,6 @@ import eu.glasskube.operator.generic.dependent.postgres.DependentPostgresSchedul import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDependent @KubernetesDependent(labelSelector = KeycloakReconciler.SELECTOR) -class KeycloakPostgresBackup : DependentPostgresScheduledBackup(Keycloak.Postgres) +class KeycloakPostgresBackup : DependentPostgresScheduledBackup(Keycloak.Postgres) { + class ReconcilePrecondition : DependentPostgresScheduledBackup.ReconcilePrecondition() +} diff --git a/operator/src/main/kotlin/eu/glasskube/operator/apps/keycloak/dependent/KeycloakPostgresBackupBucket.kt b/operator/src/main/kotlin/eu/glasskube/operator/apps/keycloak/dependent/KeycloakPostgresBackupBucket.kt index ad09bf8e..3192d730 100644 --- a/operator/src/main/kotlin/eu/glasskube/operator/apps/keycloak/dependent/KeycloakPostgresBackupBucket.kt +++ b/operator/src/main/kotlin/eu/glasskube/operator/apps/keycloak/dependent/KeycloakPostgresBackupBucket.kt @@ -6,7 +6,7 @@ import eu.glasskube.operator.apps.keycloak.Keycloak import eu.glasskube.operator.apps.keycloak.KeycloakReconciler import eu.glasskube.operator.apps.keycloak.backupBucketName import eu.glasskube.operator.apps.keycloak.resourceLabels -import eu.glasskube.operator.generic.dependent.postgres.PostgresWithoutBackupsSpecCondition +import eu.glasskube.operator.generic.dependent.postgres.backup.PostgresMinioBucketPrecondition import eu.glasskube.operator.infra.minio.MinioBucket import eu.glasskube.operator.infra.minio.MinioBucketSpec import eu.glasskube.operator.infra.minio.minioBucket @@ -16,7 +16,7 @@ import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDep @KubernetesDependent(labelSelector = KeycloakReconciler.SELECTOR) class KeycloakPostgresBackupBucket : CRUDKubernetesDependentResource(MinioBucket::class.java) { - internal class ReconcilePrecondition : PostgresWithoutBackupsSpecCondition() + internal class ReconcilePrecondition : PostgresMinioBucketPrecondition() override fun desired(primary: Keycloak, context: Context) = minioBucket { metadata { diff --git a/operator/src/main/kotlin/eu/glasskube/operator/apps/metabase/MetabaseReconciler.kt b/operator/src/main/kotlin/eu/glasskube/operator/apps/metabase/MetabaseReconciler.kt index 8004bf55..f03931ae 100644 --- a/operator/src/main/kotlin/eu/glasskube/operator/apps/metabase/MetabaseReconciler.kt +++ b/operator/src/main/kotlin/eu/glasskube/operator/apps/metabase/MetabaseReconciler.kt @@ -37,7 +37,8 @@ import io.javaoperatorsdk.operator.api.reconciler.dependent.Dependent Dependent( type = MetabasePostgresBackup::class, name = "MetabasePostgresBackup", - dependsOn = ["MetabasePostgresCluster"] + dependsOn = ["MetabasePostgresCluster"], + reconcilePrecondition = MetabasePostgresBackup.ReconcilePrecondition::class ), Dependent( type = MetabaseConfigMap::class, diff --git a/operator/src/main/kotlin/eu/glasskube/operator/apps/metabase/dependent/MetabaseMinioBucket.kt b/operator/src/main/kotlin/eu/glasskube/operator/apps/metabase/dependent/MetabaseMinioBucket.kt index c1c8d7f3..2ee6ed6f 100644 --- a/operator/src/main/kotlin/eu/glasskube/operator/apps/metabase/dependent/MetabaseMinioBucket.kt +++ b/operator/src/main/kotlin/eu/glasskube/operator/apps/metabase/dependent/MetabaseMinioBucket.kt @@ -5,7 +5,7 @@ import eu.glasskube.operator.apps.metabase.Metabase import eu.glasskube.operator.apps.metabase.MetabaseReconciler import eu.glasskube.operator.apps.metabase.genericResourceName import eu.glasskube.operator.apps.metabase.resourceLabels -import eu.glasskube.operator.generic.dependent.postgres.PostgresWithoutBackupsSpecCondition +import eu.glasskube.operator.generic.dependent.postgres.backup.PostgresMinioBucketPrecondition import eu.glasskube.operator.infra.minio.MinioBucket import eu.glasskube.operator.infra.minio.MinioBucketSpec import eu.glasskube.operator.infra.minio.minioBucket @@ -15,7 +15,7 @@ import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDep @KubernetesDependent(labelSelector = MetabaseReconciler.SELECTOR) class MetabaseMinioBucket : CRUDKubernetesDependentResource(MinioBucket::class.java) { - internal class ReconcilePrecondition : PostgresWithoutBackupsSpecCondition() + internal class ReconcilePrecondition : PostgresMinioBucketPrecondition() override fun desired(primary: Metabase, context: Context) = minioBucket { metadata { diff --git a/operator/src/main/kotlin/eu/glasskube/operator/apps/metabase/dependent/MetabasePostgresBackup.kt b/operator/src/main/kotlin/eu/glasskube/operator/apps/metabase/dependent/MetabasePostgresBackup.kt index a36aa224..ce7a8d2a 100644 --- a/operator/src/main/kotlin/eu/glasskube/operator/apps/metabase/dependent/MetabasePostgresBackup.kt +++ b/operator/src/main/kotlin/eu/glasskube/operator/apps/metabase/dependent/MetabasePostgresBackup.kt @@ -6,4 +6,6 @@ import eu.glasskube.operator.generic.dependent.postgres.DependentPostgresSchedul import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDependent @KubernetesDependent(labelSelector = MetabaseReconciler.SELECTOR) -class MetabasePostgresBackup : DependentPostgresScheduledBackup(Metabase.Postgres) +class MetabasePostgresBackup : DependentPostgresScheduledBackup(Metabase.Postgres) { + class ReconcilePrecondition : DependentPostgresScheduledBackup.ReconcilePrecondition() +} diff --git a/operator/src/main/kotlin/eu/glasskube/operator/apps/nextcloud/NextcloudReconciler.kt b/operator/src/main/kotlin/eu/glasskube/operator/apps/nextcloud/NextcloudReconciler.kt index a1b6ca45..c6886e04 100644 --- a/operator/src/main/kotlin/eu/glasskube/operator/apps/nextcloud/NextcloudReconciler.kt +++ b/operator/src/main/kotlin/eu/glasskube/operator/apps/nextcloud/NextcloudReconciler.kt @@ -55,7 +55,8 @@ import kotlin.jvm.optionals.getOrDefault Dependent( type = NextcloudPostgresBackup::class, name = "NextcloudPostgresBackup", - dependsOn = ["NextcloudPostgresCluster"] + dependsOn = ["NextcloudPostgresCluster"], + reconcilePrecondition = NextcloudPostgresBackup.ReconcilePrecondition::class ), Dependent( type = NextcloudDeployment::class, diff --git a/operator/src/main/kotlin/eu/glasskube/operator/apps/nextcloud/dependent/NextcloudMinioBucket.kt b/operator/src/main/kotlin/eu/glasskube/operator/apps/nextcloud/dependent/NextcloudMinioBucket.kt index 2b4e55e8..9c407a20 100644 --- a/operator/src/main/kotlin/eu/glasskube/operator/apps/nextcloud/dependent/NextcloudMinioBucket.kt +++ b/operator/src/main/kotlin/eu/glasskube/operator/apps/nextcloud/dependent/NextcloudMinioBucket.kt @@ -6,7 +6,7 @@ import eu.glasskube.operator.apps.nextcloud.Nextcloud import eu.glasskube.operator.apps.nextcloud.NextcloudReconciler import eu.glasskube.operator.apps.nextcloud.databaseBackupBucketName import eu.glasskube.operator.apps.nextcloud.resourceLabels -import eu.glasskube.operator.generic.dependent.postgres.PostgresWithoutBackupsSpecCondition +import eu.glasskube.operator.generic.dependent.postgres.backup.PostgresMinioBucketPrecondition import eu.glasskube.operator.infra.minio.MinioBucket import eu.glasskube.operator.infra.minio.MinioBucketSpec import eu.glasskube.operator.infra.minio.minioBucket @@ -16,7 +16,7 @@ import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDep @KubernetesDependent(labelSelector = NextcloudReconciler.SELECTOR) class NextcloudMinioBucket : CRUDKubernetesDependentResource(MinioBucket::class.java) { - internal class ReconcilePrecondition : PostgresWithoutBackupsSpecCondition() + internal class ReconcilePrecondition : PostgresMinioBucketPrecondition() override fun desired(primary: Nextcloud, context: Context) = minioBucket { metadata { diff --git a/operator/src/main/kotlin/eu/glasskube/operator/apps/nextcloud/dependent/NextcloudPostgresBackup.kt b/operator/src/main/kotlin/eu/glasskube/operator/apps/nextcloud/dependent/NextcloudPostgresBackup.kt index 1a8e84a8..5f311ab8 100644 --- a/operator/src/main/kotlin/eu/glasskube/operator/apps/nextcloud/dependent/NextcloudPostgresBackup.kt +++ b/operator/src/main/kotlin/eu/glasskube/operator/apps/nextcloud/dependent/NextcloudPostgresBackup.kt @@ -6,4 +6,6 @@ import eu.glasskube.operator.generic.dependent.postgres.DependentPostgresSchedul import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDependent @KubernetesDependent(labelSelector = NextcloudReconciler.SELECTOR) -class NextcloudPostgresBackup : DependentPostgresScheduledBackup(Nextcloud.Postgres) +class NextcloudPostgresBackup : DependentPostgresScheduledBackup(Nextcloud.Postgres) { + class ReconcilePrecondition : DependentPostgresScheduledBackup.ReconcilePrecondition() +} diff --git a/operator/src/main/kotlin/eu/glasskube/operator/apps/odoo/OdooReconciler.kt b/operator/src/main/kotlin/eu/glasskube/operator/apps/odoo/OdooReconciler.kt index 3c9fd3b8..a3060701 100644 --- a/operator/src/main/kotlin/eu/glasskube/operator/apps/odoo/OdooReconciler.kt +++ b/operator/src/main/kotlin/eu/glasskube/operator/apps/odoo/OdooReconciler.kt @@ -36,7 +36,8 @@ import io.javaoperatorsdk.operator.api.reconciler.dependent.Dependent Dependent(type = OdooIngress::class), Dependent( type = OdooPostgresScheduledBackup::class, - dependsOn = ["OdooPostgresCluster"] + dependsOn = ["OdooPostgresCluster"], + reconcilePrecondition = OdooPostgresScheduledBackup.ReconcilePrecondition::class ), Dependent( name = "OdooPostgresCluster", diff --git a/operator/src/main/kotlin/eu/glasskube/operator/apps/odoo/dependent/OdooDatabaseBackupSecret.kt b/operator/src/main/kotlin/eu/glasskube/operator/apps/odoo/dependent/OdooDatabaseBackupSecret.kt index 4f1e5e57..5a09b301 100644 --- a/operator/src/main/kotlin/eu/glasskube/operator/apps/odoo/dependent/OdooDatabaseBackupSecret.kt +++ b/operator/src/main/kotlin/eu/glasskube/operator/apps/odoo/dependent/OdooDatabaseBackupSecret.kt @@ -6,7 +6,7 @@ import eu.glasskube.operator.apps.odoo.dbBackupSecretName import eu.glasskube.operator.apps.odoo.dbBackupUsername import eu.glasskube.operator.apps.odoo.resourceLabels import eu.glasskube.operator.generic.dependent.GeneratedSecret -import eu.glasskube.operator.generic.dependent.postgres.PostgresWithoutBackupsSpecCondition +import eu.glasskube.operator.generic.dependent.postgres.backup.PostgresMinioBucketPrecondition import io.fabric8.kubernetes.api.model.Secret import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDependent @@ -14,7 +14,7 @@ import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDep labelSelector = OdooReconciler.SELECTOR ) class OdooDatabaseBackupSecret : GeneratedSecret() { - internal class ReconcilePrecondition : PostgresWithoutBackupsSpecCondition() + internal class ReconcilePrecondition : PostgresMinioBucketPrecondition() override val Odoo.generatedSecretName get() = dbBackupSecretName override val Odoo.generatedSecretLabels get() = resourceLabels diff --git a/operator/src/main/kotlin/eu/glasskube/operator/apps/odoo/dependent/OdooMinioBucket.kt b/operator/src/main/kotlin/eu/glasskube/operator/apps/odoo/dependent/OdooMinioBucket.kt index ce8e1b91..6b9cb00d 100644 --- a/operator/src/main/kotlin/eu/glasskube/operator/apps/odoo/dependent/OdooMinioBucket.kt +++ b/operator/src/main/kotlin/eu/glasskube/operator/apps/odoo/dependent/OdooMinioBucket.kt @@ -7,7 +7,7 @@ import eu.glasskube.operator.apps.odoo.bucketName import eu.glasskube.operator.apps.odoo.dbBackupSecretName import eu.glasskube.operator.apps.odoo.genericResourceName import eu.glasskube.operator.apps.odoo.resourceLabels -import eu.glasskube.operator.generic.dependent.postgres.PostgresWithoutBackupsSpecCondition +import eu.glasskube.operator.generic.dependent.postgres.backup.PostgresMinioBucketPrecondition import eu.glasskube.operator.infra.minio.MinioBucket import eu.glasskube.operator.infra.minio.MinioBucketSpec import eu.glasskube.operator.infra.minio.minioBucket @@ -18,7 +18,7 @@ import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDep @KubernetesDependent(labelSelector = OdooReconciler.SELECTOR) class OdooMinioBucket : CRUDKubernetesDependentResource(MinioBucket::class.java) { - internal class ReconcilePrecondition : PostgresWithoutBackupsSpecCondition() + internal class ReconcilePrecondition : PostgresMinioBucketPrecondition() override fun desired(primary: Odoo, context: Context) = minioBucket { metadata { diff --git a/operator/src/main/kotlin/eu/glasskube/operator/apps/odoo/dependent/OdooPostgresScheduledBackup.kt b/operator/src/main/kotlin/eu/glasskube/operator/apps/odoo/dependent/OdooPostgresScheduledBackup.kt index 247d7356..8b0cdf37 100644 --- a/operator/src/main/kotlin/eu/glasskube/operator/apps/odoo/dependent/OdooPostgresScheduledBackup.kt +++ b/operator/src/main/kotlin/eu/glasskube/operator/apps/odoo/dependent/OdooPostgresScheduledBackup.kt @@ -1,9 +1,12 @@ package eu.glasskube.operator.apps.odoo.dependent +import eu.glasskube.operator.apps.gitea.Gitea import eu.glasskube.operator.apps.odoo.Odoo import eu.glasskube.operator.apps.odoo.OdooReconciler import eu.glasskube.operator.generic.dependent.postgres.DependentPostgresScheduledBackup import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDependent @KubernetesDependent(labelSelector = OdooReconciler.SELECTOR) -class OdooPostgresScheduledBackup : DependentPostgresScheduledBackup(Odoo.Postgres) +class OdooPostgresScheduledBackup : DependentPostgresScheduledBackup(Odoo.Postgres) { + class ReconcilePrecondition : DependentPostgresScheduledBackup.ReconcilePrecondition() +} diff --git a/operator/src/main/kotlin/eu/glasskube/operator/apps/plane/PlaneReconciler.kt b/operator/src/main/kotlin/eu/glasskube/operator/apps/plane/PlaneReconciler.kt index aa19d7a7..0723b5b8 100644 --- a/operator/src/main/kotlin/eu/glasskube/operator/apps/plane/PlaneReconciler.kt +++ b/operator/src/main/kotlin/eu/glasskube/operator/apps/plane/PlaneReconciler.kt @@ -58,7 +58,8 @@ import kotlin.jvm.optionals.getOrDefault Dependent( type = PlanePostgresBackup::class, name = "PlanePostgresBackup", - dependsOn = ["PlanePostgresCluster"] + dependsOn = ["PlanePostgresCluster"], + reconcilePrecondition = PlanePostgresBackup.ReconcilePrecondition::class ), Dependent( type = PlaneRedisService::class, diff --git a/operator/src/main/kotlin/eu/glasskube/operator/apps/plane/dependent/PlanePostgresBackup.kt b/operator/src/main/kotlin/eu/glasskube/operator/apps/plane/dependent/PlanePostgresBackup.kt index 960a0baf..d228db8d 100644 --- a/operator/src/main/kotlin/eu/glasskube/operator/apps/plane/dependent/PlanePostgresBackup.kt +++ b/operator/src/main/kotlin/eu/glasskube/operator/apps/plane/dependent/PlanePostgresBackup.kt @@ -5,4 +5,6 @@ import eu.glasskube.operator.generic.dependent.postgres.DependentPostgresSchedul import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDependent @KubernetesDependent -class PlanePostgresBackup : DependentPostgresScheduledBackup(Plane.Postgres) +class PlanePostgresBackup : DependentPostgresScheduledBackup(Plane.Postgres) { + class ReconcilePrecondition : DependentPostgresScheduledBackup.ReconcilePrecondition() +} diff --git a/operator/src/main/kotlin/eu/glasskube/operator/apps/plane/dependent/PlanePostgresMinioBucket.kt b/operator/src/main/kotlin/eu/glasskube/operator/apps/plane/dependent/PlanePostgresMinioBucket.kt index d834e2c0..b69a299f 100644 --- a/operator/src/main/kotlin/eu/glasskube/operator/apps/plane/dependent/PlanePostgresMinioBucket.kt +++ b/operator/src/main/kotlin/eu/glasskube/operator/apps/plane/dependent/PlanePostgresMinioBucket.kt @@ -5,7 +5,7 @@ import eu.glasskube.kubernetes.api.model.namespace import eu.glasskube.operator.apps.plane.Plane import eu.glasskube.operator.apps.plane.Plane.Postgres.postgresClusterLabels import eu.glasskube.operator.apps.plane.Plane.Postgres.postgresClusterName -import eu.glasskube.operator.generic.dependent.postgres.PostgresWithoutBackupsSpecCondition +import eu.glasskube.operator.generic.dependent.postgres.backup.PostgresMinioBucketPrecondition import eu.glasskube.operator.infra.minio.MinioBucket import eu.glasskube.operator.infra.minio.MinioBucketSpec import eu.glasskube.operator.infra.minio.minioBucket @@ -15,7 +15,7 @@ import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDep @KubernetesDependent class PlanePostgresMinioBucket : CRUDKubernetesDependentResource(MinioBucket::class.java) { - internal class ReconcilePrecondition : PostgresWithoutBackupsSpecCondition() + internal class ReconcilePrecondition : PostgresMinioBucketPrecondition() override fun desired(primary: Plane, context: Context) = minioBucket { metadata { diff --git a/operator/src/main/kotlin/eu/glasskube/operator/apps/vault/VaultReconciler.kt b/operator/src/main/kotlin/eu/glasskube/operator/apps/vault/VaultReconciler.kt index f894a71b..14b4ca6b 100644 --- a/operator/src/main/kotlin/eu/glasskube/operator/apps/vault/VaultReconciler.kt +++ b/operator/src/main/kotlin/eu/glasskube/operator/apps/vault/VaultReconciler.kt @@ -81,7 +81,12 @@ import kotlin.jvm.optionals.getOrDefault name = "VaultStatefulSet", dependsOn = ["VaultPostgresCluster", "VaultServiceAccount", "VaultServiceHeadless", "VaultConfigMap"] ), - Dependent(type = VaultPostgresBackup::class, name = "VaultPostgresBackup", dependsOn = ["VaultPostgresCluster"]) + Dependent( + type = VaultPostgresBackup::class, + name = "VaultPostgresBackup", + dependsOn = ["VaultPostgresCluster"], + reconcilePrecondition = VaultPostgresBackup.ReconcilePrecondition::class + ) ], maxReconciliationInterval = MaxReconciliationInterval(interval = 10, timeUnit = TimeUnit.SECONDS) ) diff --git a/operator/src/main/kotlin/eu/glasskube/operator/apps/vault/dependent/VaultMinioBucket.kt b/operator/src/main/kotlin/eu/glasskube/operator/apps/vault/dependent/VaultMinioBucket.kt index 891a5afe..8787ff72 100644 --- a/operator/src/main/kotlin/eu/glasskube/operator/apps/vault/dependent/VaultMinioBucket.kt +++ b/operator/src/main/kotlin/eu/glasskube/operator/apps/vault/dependent/VaultMinioBucket.kt @@ -6,7 +6,7 @@ import eu.glasskube.operator.apps.vault.Vault import eu.glasskube.operator.apps.vault.VaultReconciler import eu.glasskube.operator.apps.vault.databaseBackupBucketName import eu.glasskube.operator.apps.vault.resourceLabels -import eu.glasskube.operator.generic.dependent.postgres.PostgresWithoutBackupsSpecCondition +import eu.glasskube.operator.generic.dependent.postgres.backup.PostgresMinioBucketPrecondition import eu.glasskube.operator.infra.minio.MinioBucket import eu.glasskube.operator.infra.minio.MinioBucketSpec import eu.glasskube.operator.infra.minio.minioBucket @@ -16,7 +16,7 @@ import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDep @KubernetesDependent(labelSelector = VaultReconciler.SELECTOR) class VaultMinioBucket : CRUDKubernetesDependentResource(MinioBucket::class.java) { - internal class ReconcilePrecondition : PostgresWithoutBackupsSpecCondition() + internal class ReconcilePrecondition : PostgresMinioBucketPrecondition() override fun desired(primary: Vault, context: Context) = minioBucket { metadata { diff --git a/operator/src/main/kotlin/eu/glasskube/operator/apps/vault/dependent/VaultPostgresBackup.kt b/operator/src/main/kotlin/eu/glasskube/operator/apps/vault/dependent/VaultPostgresBackup.kt index 9c604b55..f2bf4974 100644 --- a/operator/src/main/kotlin/eu/glasskube/operator/apps/vault/dependent/VaultPostgresBackup.kt +++ b/operator/src/main/kotlin/eu/glasskube/operator/apps/vault/dependent/VaultPostgresBackup.kt @@ -6,4 +6,6 @@ import eu.glasskube.operator.generic.dependent.postgres.DependentPostgresSchedul import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDependent @KubernetesDependent(labelSelector = VaultReconciler.SELECTOR) -class VaultPostgresBackup : DependentPostgresScheduledBackup(Vault.Postgres) +class VaultPostgresBackup : DependentPostgresScheduledBackup(Vault.Postgres) { + class ReconcilePrecondition : DependentPostgresScheduledBackup.ReconcilePrecondition() +} diff --git a/operator/src/main/kotlin/eu/glasskube/operator/generic/condition/AllCompositeCondition.kt b/operator/src/main/kotlin/eu/glasskube/operator/generic/condition/AllCompositeCondition.kt new file mode 100644 index 00000000..1e478169 --- /dev/null +++ b/operator/src/main/kotlin/eu/glasskube/operator/generic/condition/AllCompositeCondition.kt @@ -0,0 +1,13 @@ +package eu.glasskube.operator.generic.condition + +import io.fabric8.kubernetes.api.model.HasMetadata +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 AllCompositeCondition( + private vararg val conditions: Condition +) : Condition { + override fun isMet(dependentResource: DependentResource, primary: P, context: Context

) = + 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(ScheduledBackup::class.java) where P : HasMetadata, P : ResourceWithDatabaseSpec { + abstract class ReconcilePrecondition

: PostgresWithBackupsEnabledCondition() + where P : HasMetadata, P : ResourceWithDatabaseSpec + /** * The schedule that should be declared for this scheduled backup if not otherwise specified in the backup spec. * diff --git a/operator/src/main/kotlin/eu/glasskube/operator/generic/dependent/postgres/PostgresWithBackupsEnabledCondition.kt b/operator/src/main/kotlin/eu/glasskube/operator/generic/dependent/postgres/PostgresWithBackupsEnabledCondition.kt new file mode 100644 index 00000000..72d16172 --- /dev/null +++ b/operator/src/main/kotlin/eu/glasskube/operator/generic/dependent/postgres/PostgresWithBackupsEnabledCondition.kt @@ -0,0 +1,14 @@ +package eu.glasskube.operator.generic.dependent.postgres + +import eu.glasskube.operator.apps.common.database.ResourceWithDatabaseSpec +import eu.glasskube.operator.apps.common.database.postgres.PostgresDatabaseSpec +import io.fabric8.kubernetes.api.model.HasMetadata +import io.javaoperatorsdk.operator.api.reconciler.Context +import io.javaoperatorsdk.operator.api.reconciler.dependent.DependentResource +import io.javaoperatorsdk.operator.processing.dependent.workflow.Condition + +open class PostgresWithBackupsEnabledCondition : Condition +where P : HasMetadata, P : ResourceWithDatabaseSpec { + override fun isMet(dependentResource: DependentResource, primary: P, context: Context

) = + 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 : Condition +open class PostgresWithoutS3BackupsSpecCondition : Condition where P : HasMetadata, P : ResourceWithDatabaseSpec { override fun isMet(dependentResource: DependentResource, primary: P, context: Context

) = - 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 { override fun getBackupConfiguration(primary: P, context: Context

) = - 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 : AllCompositeCondition( + PostgresWithBackupsEnabledCondition(), + PostgresWithoutS3BackupsSpecCondition() +) where P : HasMetadata, P : ResourceWithDatabaseSpec