From cc9a33540929f1e9342d431052fd06f763260843 Mon Sep 17 00:00:00 2001 From: Philipp Eberle Date: Mon, 3 Mar 2025 11:51:45 +0100 Subject: [PATCH 1/2] Add custom storageClass per database --- api/v1/postgres_types.go | 9 ++++++++- api/v1/zz_generated.deepcopy.go | 5 +++++ config/crd/bases/database.fits.cloud_postgres.yaml | 3 +++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/api/v1/postgres_types.go b/api/v1/postgres_types.go index 65a8de7d..132d90a7 100644 --- a/api/v1/postgres_types.go +++ b/api/v1/postgres_types.go @@ -216,6 +216,9 @@ type PostgresSpec struct { // DisableLoadBalancers enable or disable the Load Balancers (Services) DisableLoadBalancers *bool `json:"disableLoadBalancers,omitempty"` + + // StorageClass custom storage class for this database + StorageClass *string `json:"storageClass,omitempty"` } // AccessList defines the type of restrictions to access the database @@ -707,7 +710,11 @@ func (p *Postgres) ToUnstructuredZalandoPostgresql(z *zalando.Postgresql, c *cor z.Spec.Resources.ResourceLimits.Memory = pointer.String(p.Spec.Size.Memory) z.Spec.TeamID = p.generateTeamID() z.Spec.Volume.Size = p.Spec.Size.StorageSize - z.Spec.Volume.StorageClass = sc + if p.Spec.StorageClass != nil { + z.Spec.Volume.StorageClass = *p.Spec.StorageClass + } else { + z.Spec.Volume.StorageClass = sc + } z.Spec.Patroni.TTL = patroniTTL z.Spec.Patroni.LoopWait = patroniLoopWait diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go index 54b29514..33ad01d5 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -198,6 +198,11 @@ func (in *PostgresSpec) DeepCopyInto(out *PostgresSpec) { *out = new(bool) **out = **in } + if in.StorageClass != nil { + in, out := &in.StorageClass, &out.StorageClass + *out = new(string) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PostgresSpec. diff --git a/config/crd/bases/database.fits.cloud_postgres.yaml b/config/crd/bases/database.fits.cloud_postgres.yaml index 22afd875..06545efc 100644 --- a/config/crd/bases/database.fits.cloud_postgres.yaml +++ b/config/crd/bases/database.fits.cloud_postgres.yaml @@ -175,6 +175,9 @@ spec: pattern: ^[1-9][0-9]*Gi type: string type: object + storageClass: + description: StorageClass custom storage class for this database + type: string tenant: description: Tenant metal tenant type: string From b57503f02be77fec598b5113ea4bbd3bbec19ac6 Mon Sep 17 00:00:00 2001 From: Philipp Eberle Date: Fri, 27 Jun 2025 09:11:33 +0200 Subject: [PATCH 2/2] Enable the creation of a storage encryption key by default so the encrypted storage class can be selected at any time by the user --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index e4740e5e..785fb33e 100644 --- a/main.go +++ b/main.go @@ -301,7 +301,7 @@ func main() { viper.SetDefault(enableLBSourceRangesFlg, true) enableLBSourceRanges = viper.GetBool(enableLBSourceRangesFlg) - viper.SetDefault(enableRandomStorageEncryptionSecretFlg, false) + viper.SetDefault(enableRandomStorageEncryptionSecretFlg, true) enableRandomStorageEncryptionSecret = viper.GetBool(enableRandomStorageEncryptionSecretFlg) viper.SetDefault(enableWalGEncryptionFlg, false)