Skip to content

Add custom storageClass per database #590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion api/v1/postgres_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,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
Expand Down Expand Up @@ -706,7 +709,11 @@ func (p *Postgres) ToUnstructuredZalandoPostgresql(z *zalando.Postgresql, c *cor
z.Spec.Resources.ResourceLimits.Memory = ptr.To(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
Expand Down
5 changes: 5 additions & 0 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions config/crd/bases/database.fits.cloud_postgres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,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
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ func main() {
viper.SetDefault(enableLBSourceRangesFlg, true)
enableLBSourceRanges = viper.GetBool(enableLBSourceRangesFlg)

viper.SetDefault(enableRandomStorageEncryptionSecretFlg, false)
viper.SetDefault(enableRandomStorageEncryptionSecretFlg, true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could break backward compatibility i think. So i hope you know what you are doing here (tbh: i don't know the impacts of this default inversion).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope so too :-)

Bute jokes aside: This simply does what it says, it creates a secret with a specific name and generates a random key inside it (once). When using certain encrypted storageClasses this is already enabled anyway, and other storageClasses will simply ignore it.

Should be safe.

This way, we can globally allow encrypted storage classes without having to remember to enable this flag for all environments.

Alternatively, we could simply globally enable it in the deployment. All the same to me, let's discuss this in the next meeting.

enableRandomStorageEncryptionSecret = viper.GetBool(enableRandomStorageEncryptionSecretFlg)

viper.SetDefault(enableWalGEncryptionFlg, false)
Expand Down