Merge cb65c20db9 into 1af4c50ed0
This commit is contained in:
commit
baec60e86e
|
|
@ -694,6 +694,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:
|
||||||
|
|
|
||||||
|
|
@ -584,6 +584,9 @@ spec:
|
||||||
- PreferNoSchedule
|
- PreferNoSchedule
|
||||||
tolerationSeconds:
|
tolerationSeconds:
|
||||||
type: integer
|
type: integer
|
||||||
|
useEphemeralVolume:
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
useLoadBalancer:
|
useLoadBalancer:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: deprecated
|
description: deprecated
|
||||||
|
|
|
||||||
|
|
@ -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 }}
|
||||||
|
|
|
||||||
|
|
@ -456,6 +456,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
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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:
|
||||||
|
|
|
||||||
|
|
@ -221,3 +221,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
|
||||||
|
|
@ -582,6 +582,9 @@ spec:
|
||||||
- PreferNoSchedule
|
- PreferNoSchedule
|
||||||
tolerationSeconds:
|
tolerationSeconds:
|
||||||
type: integer
|
type: integer
|
||||||
|
useEphemeralVolume:
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
useLoadBalancer:
|
useLoadBalancer:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: deprecated
|
description: deprecated
|
||||||
|
|
|
||||||
|
|
@ -895,6 +895,9 @@ var PostgresCRDResourceValidation = apiextv1.CustomResourceValidation{
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"useEphemeralVolume": {
|
||||||
|
Type: "boolean",
|
||||||
|
},
|
||||||
"useLoadBalancer": {
|
"useLoadBalancer": {
|
||||||
Type: "boolean",
|
Type: "boolean",
|
||||||
Description: "deprecated",
|
Description: "deprecated",
|
||||||
|
|
@ -1967,6 +1970,9 @@ var OperatorConfigCRDResourceValidation = apiextv1.CustomResourceValidation{
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"allow_ephemeral_volums": {
|
||||||
|
Type: "boolean",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"status": {
|
"status": {
|
||||||
|
|
|
||||||
|
|
@ -288,6 +288,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
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,9 @@ type PostgresSpec struct {
|
||||||
// deprecated json tags
|
// deprecated json tags
|
||||||
InitContainersOld []v1.Container `json:"init_containers,omitempty"`
|
InitContainersOld []v1.Container `json:"init_containers,omitempty"`
|
||||||
PodPriorityClassNameOld string `json:"pod_priority_class_name,omitempty"`
|
PodPriorityClassNameOld string `json:"pod_priority_class_name,omitempty"`
|
||||||
|
|
||||||
|
// Ephemeral settings
|
||||||
|
UseEphemeralVolume *bool `json:"useEphemeralVolume,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||||
|
|
|
||||||
|
|
@ -466,6 +466,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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -881,6 +886,11 @@ func (in *PostgresSpec) DeepCopyInto(out *PostgresSpec) {
|
||||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if in.UseEphemeralVolume != nil {
|
||||||
|
in, out := &in.UseEphemeralVolume, &out.UseEphemeralVolume
|
||||||
|
*out = new(bool)
|
||||||
|
**out = **in
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1287,10 +1287,12 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*appsv1.Statef
|
||||||
initContainers []v1.Container
|
initContainers []v1.Container
|
||||||
sidecarContainers []v1.Container
|
sidecarContainers []v1.Container
|
||||||
podTemplate *v1.PodTemplateSpec
|
podTemplate *v1.PodTemplateSpec
|
||||||
volumeClaimTemplate *v1.PersistentVolumeClaim
|
volumeClaimTemplate *[]v1.PersistentVolumeClaim
|
||||||
additionalVolumes = spec.AdditionalVolumes
|
additionalVolumes = spec.AdditionalVolumes
|
||||||
)
|
)
|
||||||
|
|
||||||
|
useEphemeralVolume := c.OpConfig.AllowEphemeralVolumes != nil && spec.UseEphemeralVolume != nil && (*c.OpConfig.AllowEphemeralVolumes && *spec.UseEphemeralVolume)
|
||||||
|
|
||||||
defaultResources := makeDefaultResources(&c.OpConfig)
|
defaultResources := makeDefaultResources(&c.OpConfig)
|
||||||
resourceRequirements, err := c.generateResourceRequirements(
|
resourceRequirements, err := c.generateResourceRequirements(
|
||||||
spec.Resources, defaultResources, constants.PostgresContainerName)
|
spec.Resources, defaultResources, constants.PostgresContainerName)
|
||||||
|
|
@ -1491,10 +1493,24 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*appsv1.Statef
|
||||||
return nil, fmt.Errorf("could not generate pod template: %v", err)
|
return nil, fmt.Errorf("could not generate pod template: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Generate the volumes, optionally using an ephemeral volume
|
||||||
|
if useEphemeralVolume {
|
||||||
|
empty := make([]v1.PersistentVolumeClaim, 0)
|
||||||
|
volumeClaimTemplate = &empty
|
||||||
|
|
||||||
|
// Also add the ephemeral volume to the spec
|
||||||
|
podTemplate.Spec.Volumes = append(podTemplate.Spec.Volumes, v1.Volume{
|
||||||
|
Name: constants.DataVolumeName,
|
||||||
|
VolumeSource: v1.VolumeSource{
|
||||||
|
EmptyDir: &v1.EmptyDirVolumeSource{},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
} else {
|
||||||
if volumeClaimTemplate, err = c.generatePersistentVolumeClaimTemplate(spec.Volume.Size,
|
if volumeClaimTemplate, err = c.generatePersistentVolumeClaimTemplate(spec.Volume.Size,
|
||||||
spec.Volume.StorageClass, spec.Volume.Selector); err != nil {
|
spec.Volume.StorageClass, spec.Volume.Selector); err != nil {
|
||||||
return nil, fmt.Errorf("could not generate volume claim template: %v", err)
|
return nil, fmt.Errorf("could not generate volume claim template: %v", err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// global minInstances and maxInstances settings can overwrite manifest
|
// global minInstances and maxInstances settings can overwrite manifest
|
||||||
numberOfInstances := c.getNumberOfInstances(spec)
|
numberOfInstances := c.getNumberOfInstances(spec)
|
||||||
|
|
@ -1540,7 +1556,7 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*appsv1.Statef
|
||||||
Selector: c.labelsSelector(),
|
Selector: c.labelsSelector(),
|
||||||
ServiceName: c.serviceName(Master),
|
ServiceName: c.serviceName(Master),
|
||||||
Template: *podTemplate,
|
Template: *podTemplate,
|
||||||
VolumeClaimTemplates: []v1.PersistentVolumeClaim{*volumeClaimTemplate},
|
VolumeClaimTemplates: *volumeClaimTemplate,
|
||||||
UpdateStrategy: updateStrategy,
|
UpdateStrategy: updateStrategy,
|
||||||
PodManagementPolicy: podManagementPolicy,
|
PodManagementPolicy: podManagementPolicy,
|
||||||
PersistentVolumeClaimRetentionPolicy: &persistentVolumeClaimRetentionPolicy,
|
PersistentVolumeClaimRetentionPolicy: &persistentVolumeClaimRetentionPolicy,
|
||||||
|
|
@ -1848,7 +1864,7 @@ func (c *Cluster) addAdditionalVolumes(podSpec *v1.PodSpec,
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cluster) generatePersistentVolumeClaimTemplate(volumeSize, volumeStorageClass string,
|
func (c *Cluster) generatePersistentVolumeClaimTemplate(volumeSize, volumeStorageClass string,
|
||||||
volumeSelector *metav1.LabelSelector) (*v1.PersistentVolumeClaim, error) {
|
volumeSelector *metav1.LabelSelector) (*[]v1.PersistentVolumeClaim, error) {
|
||||||
|
|
||||||
var storageClassName *string
|
var storageClassName *string
|
||||||
if volumeStorageClass != "" {
|
if volumeStorageClass != "" {
|
||||||
|
|
@ -1861,7 +1877,7 @@ func (c *Cluster) generatePersistentVolumeClaimTemplate(volumeSize, volumeStorag
|
||||||
}
|
}
|
||||||
|
|
||||||
volumeMode := v1.PersistentVolumeFilesystem
|
volumeMode := v1.PersistentVolumeFilesystem
|
||||||
volumeClaim := &v1.PersistentVolumeClaim{
|
volumeClaim := v1.PersistentVolumeClaim{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: constants.DataVolumeName,
|
Name: constants.DataVolumeName,
|
||||||
Annotations: c.annotationsSet(nil),
|
Annotations: c.annotationsSet(nil),
|
||||||
|
|
@ -1880,7 +1896,7 @@ func (c *Cluster) generatePersistentVolumeClaimTemplate(volumeSize, volumeStorag
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
return volumeClaim, nil
|
return &[]v1.PersistentVolumeClaim{volumeClaim}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cluster) generateUserSecrets() map[string]*v1.Secret {
|
func (c *Cluster) generateUserSecrets() map[string]*v1.Secret {
|
||||||
|
|
|
||||||
|
|
@ -278,5 +278,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
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -254,6 +254,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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue