add operator config for ephemeral volumes

This commit is contained in:
Nicholas Cioli 2024-07-11 20:39:32 -04:00
parent e71891e2bd
commit 8a5b6b1408
No known key found for this signature in database
GPG Key ID: 6DD5101305A51813
12 changed files with 29 additions and 0 deletions

View File

@ -692,6 +692,9 @@ spec:
enable_patroni_failsafe_mode: enable_patroni_failsafe_mode:
type: boolean type: boolean
default: false default: false
allow_ephemeral_volumes:
type: boolean
default: false
status: status:
type: object type: object
additionalProperties: additionalProperties:

View File

@ -42,4 +42,5 @@ configuration:
{{ tpl (toYaml .Values.configConnectionPooler) . | indent 4 }} {{ tpl (toYaml .Values.configConnectionPooler) . | indent 4 }}
patroni: patroni:
{{ tpl (toYaml .Values.configPatroni) . | indent 4 }} {{ tpl (toYaml .Values.configPatroni) . | indent 4 }}
allow_ephemeral_volumes: {{ .Values.allowEphemeralVolumes }}
{{- end }} {{- end }}

View File

@ -454,6 +454,9 @@ configPatroni:
# Zalando's internal CDC stream feature # Zalando's internal CDC stream feature
enableStreams: false enableStreams: false
# Allow ephemeral instances
allowEphemeralVolumes: false
rbac: rbac:
# Specifies whether RBAC resources should be created # Specifies whether RBAC resources should be created
create: true create: true

View File

@ -7,6 +7,7 @@ data:
# additional_pod_capabilities: "SYS_NICE" # additional_pod_capabilities: "SYS_NICE"
# additional_secret_mount: "some-secret-name" # additional_secret_mount: "some-secret-name"
# additional_secret_mount_path: "/some/dir" # additional_secret_mount_path: "/some/dir"
# allow_ephemeral_volumes: true
api_port: "8080" api_port: "8080"
aws_region: eu-central-1 aws_region: eu-central-1
cluster_domain: cluster.local cluster_domain: cluster.local

View File

@ -690,6 +690,9 @@ spec:
enable_patroni_failsafe_mode: enable_patroni_failsafe_mode:
type: boolean type: boolean
default: false default: false
allow_ephemeral_volumes:
type: boolean
default: false
status: status:
type: object type: object
additionalProperties: additionalProperties:

View File

@ -220,3 +220,4 @@ configuration:
# connection_pooler_user: "pooler" # connection_pooler_user: "pooler"
patroni: patroni:
enable_patroni_failsafe_mode: false enable_patroni_failsafe_mode: false
allow_ephemeral_volumes: false

View File

@ -1966,6 +1966,9 @@ var OperatorConfigCRDResourceValidation = apiextv1.CustomResourceValidation{
}, },
}, },
}, },
"allow_ephemeral_volums": {
Type: "boolean",
},
}, },
}, },
"status": { "status": {

View File

@ -287,6 +287,8 @@ type OperatorConfigurationData struct {
MinInstances int32 `json:"min_instances,omitempty"` MinInstances int32 `json:"min_instances,omitempty"`
MaxInstances int32 `json:"max_instances,omitempty"` MaxInstances int32 `json:"max_instances,omitempty"`
IgnoreInstanceLimitsAnnotationKey string `json:"ignore_instance_limits_annotation_key,omitempty"` IgnoreInstanceLimitsAnnotationKey string `json:"ignore_instance_limits_annotation_key,omitempty"`
AllowEphemeralVolumes *bool `json:"allow_ephemeral_volumes,omitempty"`
} }
// Duration shortens this frequently used name // Duration shortens this frequently used name

View File

@ -461,6 +461,11 @@ func (in *OperatorConfigurationData) DeepCopyInto(out *OperatorConfigurationData
out.LogicalBackup = in.LogicalBackup out.LogicalBackup = in.LogicalBackup
in.ConnectionPooler.DeepCopyInto(&out.ConnectionPooler) in.ConnectionPooler.DeepCopyInto(&out.ConnectionPooler)
in.Patroni.DeepCopyInto(&out.Patroni) in.Patroni.DeepCopyInto(&out.Patroni)
if in.AllowEphemeralVolumes != nil {
in, out := &in.AllowEphemeralVolumes, &out.AllowEphemeralVolumes
*out = new(bool)
**out = **in
}
return return
} }

View File

@ -692,6 +692,7 @@ func generateContainer(
privilegedMode bool, privilegedMode bool,
privilegeEscalationMode *bool, privilegeEscalationMode *bool,
additionalPodCapabilities *v1.Capabilities, additionalPodCapabilities *v1.Capabilities,
useEphemeralVolumes *bool,
) *v1.Container { ) *v1.Container {
return &v1.Container{ return &v1.Container{
Name: name, Name: name,
@ -1394,6 +1395,7 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*appsv1.Statef
c.OpConfig.Resources.SpiloPrivileged, c.OpConfig.Resources.SpiloPrivileged,
c.OpConfig.Resources.SpiloAllowPrivilegeEscalation, c.OpConfig.Resources.SpiloAllowPrivilegeEscalation,
generateCapabilities(c.OpConfig.AdditionalPodCapabilities), generateCapabilities(c.OpConfig.AdditionalPodCapabilities),
nil,
) )
// Patroni responds 200 to probe only if it either owns the leader lock or postgres is running and DCS is accessible // Patroni responds 200 to probe only if it either owns the leader lock or postgres is running and DCS is accessible
@ -2288,6 +2290,7 @@ func (c *Cluster) generateLogicalBackupJob() (*batchv1.CronJob, error) {
c.OpConfig.SpiloPrivileged, // use same value as for normal DB pods c.OpConfig.SpiloPrivileged, // use same value as for normal DB pods
c.OpConfig.SpiloAllowPrivilegeEscalation, c.OpConfig.SpiloAllowPrivilegeEscalation,
nil, nil,
nil,
) )
logicalBackupJobLabel := map[string]string{ logicalBackupJobLabel := map[string]string{

View File

@ -277,5 +277,8 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur
fromCRD.ConnectionPooler.MaxDBConnections, fromCRD.ConnectionPooler.MaxDBConnections,
k8sutil.Int32ToPointer(constants.ConnectionPoolerMaxDBConnections)) k8sutil.Int32ToPointer(constants.ConnectionPoolerMaxDBConnections))
// Ephemeral config
result.AllowEphemeralVolumes = util.CoalesceBool(fromCRD.AllowEphemeralVolumes, util.False())
return result return result
} }

View File

@ -253,6 +253,7 @@ type Config struct {
EnableSecretsDeletion *bool `name:"enable_secrets_deletion" default:"true"` EnableSecretsDeletion *bool `name:"enable_secrets_deletion" default:"true"`
EnablePersistentVolumeClaimDeletion *bool `name:"enable_persistent_volume_claim_deletion" default:"true"` EnablePersistentVolumeClaimDeletion *bool `name:"enable_persistent_volume_claim_deletion" default:"true"`
PersistentVolumeClaimRetentionPolicy map[string]string `name:"persistent_volume_claim_retention_policy" default:"when_deleted:retain,when_scaled:retain"` PersistentVolumeClaimRetentionPolicy map[string]string `name:"persistent_volume_claim_retention_policy" default:"when_deleted:retain,when_scaled:retain"`
AllowEphemeralVolumes *bool `json:"allow_ephemeral_volumes,omitempty"`
} }
// MustMarshal marshals the config or panics // MustMarshal marshals the config or panics