From d213ca462c5fd765548f851626c9439022ad77cc Mon Sep 17 00:00:00 2001 From: Igor Yanchenko Date: Tue, 5 May 2020 14:56:50 +0200 Subject: [PATCH 01/17] Try to resize pvc if resizing pv has failed --- pkg/cluster/sync.go | 7 ++++++- pkg/cluster/volumes.go | 29 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/pkg/cluster/sync.go b/pkg/cluster/sync.go index e49bd4537..c181de2d9 100644 --- a/pkg/cluster/sync.go +++ b/pkg/cluster/sync.go @@ -583,7 +583,12 @@ func (c *Cluster) syncVolumes() error { return nil } if err := c.resizeVolumes(c.Spec.Volume, []volumes.VolumeResizer{&volumes.EBSVolumeResizer{AWSRegion: c.OpConfig.AWSRegion}}); err != nil { - return fmt.Errorf("could not sync volumes: %v", err) + c.logger.Infof("could not sync volumes: %v", err) + c.logger.Infof("trying to update volume claim") + if err := c.resizeVolumeClaims(c.Spec.Volume); err != nil { + return fmt.Errorf("could not sync volume claims: %v", err) + } + return nil } c.logger.Infof("volumes have been synced successfully") diff --git a/pkg/cluster/volumes.go b/pkg/cluster/volumes.go index a5bfe6c2d..5d4de6742 100644 --- a/pkg/cluster/volumes.go +++ b/pkg/cluster/volumes.go @@ -52,6 +52,35 @@ func (c *Cluster) deletePersistentVolumeClaims() error { return nil } +func (c *Cluster) resizeVolumeClaims(newVolume acidv1.Volume) error { + c.logger.Debugln("resizing PVCs") + pvcs, err := c.listPersistentVolumeClaims() + if err != nil { + return err + } + newQuantity, err := resource.ParseQuantity(newVolume.Size) + if err != nil { + return fmt.Errorf("could not parse volume size: %v", err) + } + _, newSize, err := c.listVolumesWithManifestSize(newVolume) + for _, pvc := range pvcs { + volumeSize := quantityToGigabyte(pvc.Spec.Resources.Requests[v1.ResourceStorage]) + if volumeSize >= newSize { + if volumeSize > newSize { + c.logger.Warningf("cannot shrink persistent volume") + } + continue + } + pvc.Spec.Resources.Requests[v1.ResourceStorage] = newQuantity + c.logger.Debugf("updating persistent volume claim definition for volume %q", pvc.Name) + if _, err := c.KubeClient.PersistentVolumeClaims(pvc.Namespace).Update(context.TODO(), &pvc, metav1.UpdateOptions{}); err != nil { + return fmt.Errorf("could not update persistent volume claim: %q", err) + } + c.logger.Debugf("successfully updated persistent volume claim %q", pvc.Name) + } + return nil +} + func (c *Cluster) listPersistentVolumes() ([]*v1.PersistentVolume, error) { result := make([]*v1.PersistentVolume, 0) From 2832ec3b4b0de2452f0d7bb5c508852aa2f01423 Mon Sep 17 00:00:00 2001 From: Igor Yanchenko Date: Thu, 7 May 2020 09:24:57 +0200 Subject: [PATCH 02/17] added config option to switch between storage resize strategies --- manifests/operatorconfiguration.crd.yaml | 2 ++ pkg/apis/acid.zalan.do/v1/crds.go | 3 +++ pkg/apis/acid.zalan.do/v1/operator_configuration_type.go | 1 + pkg/cluster/sync.go | 9 +++++---- pkg/controller/operator_config.go | 1 + pkg/util/config/config.go | 1 + 6 files changed, 13 insertions(+), 4 deletions(-) diff --git a/manifests/operatorconfiguration.crd.yaml b/manifests/operatorconfiguration.crd.yaml index 364ea6d5a..ef568a448 100644 --- a/manifests/operatorconfiguration.crd.yaml +++ b/manifests/operatorconfiguration.crd.yaml @@ -123,6 +123,8 @@ spec: type: boolean enable_pod_disruption_budget: type: boolean + enable_pvc_resize: + type: boolean enable_sidecars: type: boolean infrastructure_roles_secret_name: diff --git a/pkg/apis/acid.zalan.do/v1/crds.go b/pkg/apis/acid.zalan.do/v1/crds.go index 43410ed3b..359dbd467 100644 --- a/pkg/apis/acid.zalan.do/v1/crds.go +++ b/pkg/apis/acid.zalan.do/v1/crds.go @@ -905,6 +905,9 @@ var OperatorConfigCRDResourceValidation = apiextv1beta1.CustomResourceValidation "enable_pod_disruption_budget": { Type: "boolean", }, + "enable_pvc_resize": { + Type: "boolean", + }, "enable_sidecars": { Type: "boolean", }, diff --git a/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go b/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go index 2dd0bbb50..6f53803e4 100644 --- a/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go +++ b/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go @@ -53,6 +53,7 @@ type KubernetesMetaConfiguration struct { WatchedNamespace string `json:"watched_namespace,omitempty"` PDBNameFormat config.StringTemplate `json:"pdb_name_format,omitempty"` EnablePodDisruptionBudget *bool `json:"enable_pod_disruption_budget,omitempty"` + EnablePvcResize bool `json:"enable_pvc_resize,omitempty"` EnableInitContainers *bool `json:"enable_init_containers,omitempty"` EnableSidecars *bool `json:"enable_sidecars,omitempty"` SecretNameTemplate config.StringTemplate `json:"secret_name_template,omitempty"` diff --git a/pkg/cluster/sync.go b/pkg/cluster/sync.go index c181de2d9..385424f87 100644 --- a/pkg/cluster/sync.go +++ b/pkg/cluster/sync.go @@ -582,13 +582,14 @@ func (c *Cluster) syncVolumes() error { if !act { return nil } - if err := c.resizeVolumes(c.Spec.Volume, []volumes.VolumeResizer{&volumes.EBSVolumeResizer{AWSRegion: c.OpConfig.AWSRegion}}); err != nil { - c.logger.Infof("could not sync volumes: %v", err) - c.logger.Infof("trying to update volume claim") + if c.OpConfig.EnablePvcResize { if err := c.resizeVolumeClaims(c.Spec.Volume); err != nil { return fmt.Errorf("could not sync volume claims: %v", err) } - return nil + } else { + if err := c.resizeVolumes(c.Spec.Volume, []volumes.VolumeResizer{&volumes.EBSVolumeResizer{AWSRegion: c.OpConfig.AWSRegion}}); err != nil { + return fmt.Errorf("could not sync volumes: %v", err) + } } c.logger.Infof("volumes have been synced successfully") diff --git a/pkg/controller/operator_config.go b/pkg/controller/operator_config.go index bfb0e6dcc..5e8db570a 100644 --- a/pkg/controller/operator_config.go +++ b/pkg/controller/operator_config.go @@ -65,6 +65,7 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur result.WatchedNamespace = fromCRD.Kubernetes.WatchedNamespace result.PDBNameFormat = fromCRD.Kubernetes.PDBNameFormat result.EnablePodDisruptionBudget = util.CoalesceBool(fromCRD.Kubernetes.EnablePodDisruptionBudget, util.True()) + result.EnablePvcResize = fromCRD.Kubernetes.EnablePvcResize result.EnableInitContainers = util.CoalesceBool(fromCRD.Kubernetes.EnableInitContainers, util.True()) result.EnableSidecars = util.CoalesceBool(fromCRD.Kubernetes.EnableSidecars, util.True()) result.SecretNameTemplate = fromCRD.Kubernetes.SecretNameTemplate diff --git a/pkg/util/config/config.go b/pkg/util/config/config.go index 01057f236..d7b6497d9 100644 --- a/pkg/util/config/config.go +++ b/pkg/util/config/config.go @@ -142,6 +142,7 @@ type Config struct { CustomPodAnnotations map[string]string `name:"custom_pod_annotations"` EnablePodAntiAffinity bool `name:"enable_pod_antiaffinity" default:"false"` PodAntiAffinityTopologyKey string `name:"pod_antiaffinity_topology_key" default:"kubernetes.io/hostname"` + EnablePvcResize bool `name:"enable_pvc_resize" default:"false"` // deprecated and kept for backward compatibility EnableLoadBalancer *bool `name:"enable_load_balancer"` MasterDNSNameFormat StringTemplate `name:"master_dns_name_format" default:"{cluster}.{team}.{hostedzone}"` From f882e97cddc6a105d255ce83416c000ed347b8fe Mon Sep 17 00:00:00 2001 From: Igor Yanchenko Date: Thu, 11 Jun 2020 15:14:18 +0200 Subject: [PATCH 03/17] changes according to requests --- manifests/operatorconfiguration.crd.yaml | 8 ++- pkg/apis/acid.zalan.do/v1/crds.go | 15 ++++- .../v1/operator_configuration_type.go | 2 +- pkg/cluster/sync.go | 60 +++++++++++++------ pkg/cluster/volumes.go | 19 ++++++ pkg/controller/operator_config.go | 2 +- pkg/util/config/config.go | 2 +- 7 files changed, 83 insertions(+), 25 deletions(-) diff --git a/manifests/operatorconfiguration.crd.yaml b/manifests/operatorconfiguration.crd.yaml index ef568a448..e2ad392c0 100644 --- a/manifests/operatorconfiguration.crd.yaml +++ b/manifests/operatorconfiguration.crd.yaml @@ -123,8 +123,12 @@ spec: type: boolean enable_pod_disruption_budget: type: boolean - enable_pvc_resize: - type: boolean + enable_storage_resize: + type: string + enum: + - "ebs" + - "pvc" + - "off" enable_sidecars: type: boolean infrastructure_roles_secret_name: diff --git a/pkg/apis/acid.zalan.do/v1/crds.go b/pkg/apis/acid.zalan.do/v1/crds.go index 359dbd467..693fca3fa 100644 --- a/pkg/apis/acid.zalan.do/v1/crds.go +++ b/pkg/apis/acid.zalan.do/v1/crds.go @@ -905,8 +905,19 @@ var OperatorConfigCRDResourceValidation = apiextv1beta1.CustomResourceValidation "enable_pod_disruption_budget": { Type: "boolean", }, - "enable_pvc_resize": { - Type: "boolean", + "enable_storage_resize": { + Type: "string", + Enum: []apiextv1beta1.JSON{ + { + Raw: []byte(`"ebs"`), + }, + { + Raw: []byte(`"pvc"`), + }, + { + Raw: []byte(`"off"`), + }, + }, }, "enable_sidecars": { Type: "boolean", diff --git a/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go b/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go index 6f53803e4..c32bad776 100644 --- a/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go +++ b/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go @@ -53,7 +53,7 @@ type KubernetesMetaConfiguration struct { WatchedNamespace string `json:"watched_namespace,omitempty"` PDBNameFormat config.StringTemplate `json:"pdb_name_format,omitempty"` EnablePodDisruptionBudget *bool `json:"enable_pod_disruption_budget,omitempty"` - EnablePvcResize bool `json:"enable_pvc_resize,omitempty"` + EnableStorageResize string `json:"enable_storage_resize,omitempty"` EnableInitContainers *bool `json:"enable_init_containers,omitempty"` EnableSidecars *bool `json:"enable_sidecars,omitempty"` SecretNameTemplate config.StringTemplate `json:"secret_name_template,omitempty"` diff --git a/pkg/cluster/sync.go b/pkg/cluster/sync.go index 385424f87..3034824ab 100644 --- a/pkg/cluster/sync.go +++ b/pkg/cluster/sync.go @@ -57,16 +57,26 @@ func (c *Cluster) Sync(newSpec *acidv1.Postgresql) error { return err } - // potentially enlarge volumes before changing the statefulset. By doing that - // in this order we make sure the operator is not stuck waiting for a pod that - // cannot start because it ran out of disk space. - // TODO: handle the case of the cluster that is downsized and enlarged again - // (there will be a volume from the old pod for which we can't act before the - // the statefulset modification is concluded) - c.logger.Debugf("syncing persistent volumes") - if err = c.syncVolumes(); err != nil { - err = fmt.Errorf("could not sync persistent volumes: %v", err) - return err + if c.OpConfig.EnableStorageResize == "pvc" { + c.logger.Debugf("syncing persistent volume claims") + if err = c.syncVolumeClaims(); err != nil { + err = fmt.Errorf("could not sync persistent volume claims: %v", err) + return err + } + } else if c.OpConfig.EnableStorageResize == "ebs" { + // potentially enlarge volumes before changing the statefulset. By doing that + // in this order we make sure the operator is not stuck waiting for a pod that + // cannot start because it ran out of disk space. + // TODO: handle the case of the cluster that is downsized and enlarged again + // (there will be a volume from the old pod for which we can't act before the + // the statefulset modification is concluded) + c.logger.Debugf("syncing persistent volumes") + if err = c.syncVolumes(); err != nil { + err = fmt.Errorf("could not sync persistent volumes: %v", err) + return err + } + } else { + c.logger.Infof("Storage resize is disabled (enable_storage_resize is off). Skipping volume sync.") } if err = c.enforceMinResourceLimits(&c.Spec); err != nil { @@ -571,6 +581,26 @@ func (c *Cluster) syncRoles() (err error) { return nil } +// syncVolumeClaims reads all persistent volume claims and checks that their size matches the one declared in the statefulset. +func (c *Cluster) syncVolumeClaims() error { + c.setProcessName("syncing volume claims") + + act, err := c.volumeClaimsNeedResizing(c.Spec.Volume) + if err != nil { + return fmt.Errorf("could not compare size of the volume claims: %v", err) + } + if !act { + return nil + } + if err := c.resizeVolumeClaims(c.Spec.Volume); err != nil { + return fmt.Errorf("could not sync volume claims: %v", err) + } + + c.logger.Infof("volume claims have been synced successfully") + + return nil +} + // syncVolumes reads all persistent volumes and checks that their size matches the one declared in the statefulset. func (c *Cluster) syncVolumes() error { c.setProcessName("syncing volumes") @@ -582,14 +612,8 @@ func (c *Cluster) syncVolumes() error { if !act { return nil } - if c.OpConfig.EnablePvcResize { - if err := c.resizeVolumeClaims(c.Spec.Volume); err != nil { - return fmt.Errorf("could not sync volume claims: %v", err) - } - } else { - if err := c.resizeVolumes(c.Spec.Volume, []volumes.VolumeResizer{&volumes.EBSVolumeResizer{AWSRegion: c.OpConfig.AWSRegion}}); err != nil { - return fmt.Errorf("could not sync volumes: %v", err) - } + if err := c.resizeVolumes(c.Spec.Volume, []volumes.VolumeResizer{&volumes.EBSVolumeResizer{AWSRegion: c.OpConfig.AWSRegion}}); err != nil { + return fmt.Errorf("could not sync volumes: %v", err) } c.logger.Infof("volumes have been synced successfully") diff --git a/pkg/cluster/volumes.go b/pkg/cluster/volumes.go index 5d4de6742..b75a85859 100644 --- a/pkg/cluster/volumes.go +++ b/pkg/cluster/volumes.go @@ -189,6 +189,25 @@ func (c *Cluster) resizeVolumes(newVolume acidv1.Volume, resizers []volumes.Volu return nil } +func (c *Cluster) volumeClaimsNeedResizing(newVolume acidv1.Volume) (bool, error) { + newSize, err := resource.ParseQuantity(newVolume.Size) + manifestSize := quantityToGigabyte(newSize) + if err != nil { + return false, fmt.Errorf("could not parse volume size from the manifest: %v", err) + } + pvcs, err := c.listPersistentVolumeClaims() + if err != nil { + return false, fmt.Errorf("could not receive persistent volume claims: %v", err) + } + for _, pvc := range pvcs { + currentSize := quantityToGigabyte(pvc.Spec.Resources.Requests[v1.ResourceStorage]) + if currentSize != manifestSize { + return true, nil + } + } + return false, nil +} + func (c *Cluster) volumesNeedResizing(newVolume acidv1.Volume) (bool, error) { vols, manifestSize, err := c.listVolumesWithManifestSize(newVolume) if err != nil { diff --git a/pkg/controller/operator_config.go b/pkg/controller/operator_config.go index 5e8db570a..2342d81c0 100644 --- a/pkg/controller/operator_config.go +++ b/pkg/controller/operator_config.go @@ -65,7 +65,7 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur result.WatchedNamespace = fromCRD.Kubernetes.WatchedNamespace result.PDBNameFormat = fromCRD.Kubernetes.PDBNameFormat result.EnablePodDisruptionBudget = util.CoalesceBool(fromCRD.Kubernetes.EnablePodDisruptionBudget, util.True()) - result.EnablePvcResize = fromCRD.Kubernetes.EnablePvcResize + result.EnableStorageResize = fromCRD.Kubernetes.EnableStorageResize result.EnableInitContainers = util.CoalesceBool(fromCRD.Kubernetes.EnableInitContainers, util.True()) result.EnableSidecars = util.CoalesceBool(fromCRD.Kubernetes.EnableSidecars, util.True()) result.SecretNameTemplate = fromCRD.Kubernetes.SecretNameTemplate diff --git a/pkg/util/config/config.go b/pkg/util/config/config.go index d7b6497d9..77609fa88 100644 --- a/pkg/util/config/config.go +++ b/pkg/util/config/config.go @@ -142,7 +142,7 @@ type Config struct { CustomPodAnnotations map[string]string `name:"custom_pod_annotations"` EnablePodAntiAffinity bool `name:"enable_pod_antiaffinity" default:"false"` PodAntiAffinityTopologyKey string `name:"pod_antiaffinity_topology_key" default:"kubernetes.io/hostname"` - EnablePvcResize bool `name:"enable_pvc_resize" default:"false"` + EnableStorageResize string `name:"enable_storage_resize" default:"ebs"` // deprecated and kept for backward compatibility EnableLoadBalancer *bool `name:"enable_load_balancer"` MasterDNSNameFormat StringTemplate `name:"master_dns_name_format" default:"{cluster}.{team}.{hostedzone}"` From f3b5359d123628c5a419f15a1aa1b028bd9a4f5d Mon Sep 17 00:00:00 2001 From: Igor Yanchenko <1504692+yanchenko-igor@users.noreply.github.com> Date: Fri, 12 Jun 2020 13:50:16 +0200 Subject: [PATCH 04/17] Update pkg/controller/operator_config.go Co-authored-by: Felix Kunde --- pkg/controller/operator_config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/controller/operator_config.go b/pkg/controller/operator_config.go index 2342d81c0..b7927ccba 100644 --- a/pkg/controller/operator_config.go +++ b/pkg/controller/operator_config.go @@ -65,7 +65,7 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur result.WatchedNamespace = fromCRD.Kubernetes.WatchedNamespace result.PDBNameFormat = fromCRD.Kubernetes.PDBNameFormat result.EnablePodDisruptionBudget = util.CoalesceBool(fromCRD.Kubernetes.EnablePodDisruptionBudget, util.True()) - result.EnableStorageResize = fromCRD.Kubernetes.EnableStorageResize + result.EnableStorageResize = util.Coalesce(fromCRD.Kubernetes.EnableStorageResize, "ebs") result.EnableInitContainers = util.CoalesceBool(fromCRD.Kubernetes.EnableInitContainers, util.True()) result.EnableSidecars = util.CoalesceBool(fromCRD.Kubernetes.EnableSidecars, util.True()) result.SecretNameTemplate = fromCRD.Kubernetes.SecretNameTemplate From 0d6615c4dd3c5abacdf320b09eb22ac4d2d08349 Mon Sep 17 00:00:00 2001 From: Igor Yanchenko Date: Mon, 15 Jun 2020 09:29:44 +0200 Subject: [PATCH 05/17] enable_storage_resize documented added examples to the default configuration and helm value files --- charts/postgres-operator/values-crd.yaml | 2 ++ charts/postgres-operator/values.yaml | 2 ++ docs/reference/operator_parameters.md | 5 +++++ manifests/configmap.yaml | 1 + manifests/postgresql-operator-default-configuration.yaml | 1 + pkg/cluster/volumes.go | 2 +- 6 files changed, 12 insertions(+), 1 deletion(-) diff --git a/charts/postgres-operator/values-crd.yaml b/charts/postgres-operator/values-crd.yaml index 14287fdaf..a86806b7c 100644 --- a/charts/postgres-operator/values-crd.yaml +++ b/charts/postgres-operator/values-crd.yaml @@ -80,6 +80,8 @@ configKubernetes: enable_pod_disruption_budget: true # enables sidecar containers to run alongside Spilo in the same pod enable_sidecars: true + # storage resize strategy, available options are: ebs, pvc, off + enable_storage_resize: ebs # namespaced name of the secret containing infrastructure roles names and passwords # infrastructure_roles_secret_name: postgresql-infrastructure-roles diff --git a/charts/postgres-operator/values.yaml b/charts/postgres-operator/values.yaml index cce0b79c8..a6a602b29 100644 --- a/charts/postgres-operator/values.yaml +++ b/charts/postgres-operator/values.yaml @@ -74,6 +74,8 @@ configKubernetes: enable_pod_disruption_budget: "true" # enables sidecar containers to run alongside Spilo in the same pod enable_sidecars: "true" + # storage resize strategy, available options are: ebs, pvc, off + enable_storage_resize: ebs # namespaced name of the secret containing infrastructure roles names and passwords # infrastructure_roles_secret_name: postgresql-infrastructure-roles diff --git a/docs/reference/operator_parameters.md b/docs/reference/operator_parameters.md index f8189f913..42ff8b9a2 100644 --- a/docs/reference/operator_parameters.md +++ b/docs/reference/operator_parameters.md @@ -234,6 +234,11 @@ configuration they are grouped under the `kubernetes` key. to run alongside Spilo on the same pod. Globally defined sidecars are always enabled. Default is true. +* **enable_storage_resize** + defines how operator handels the difference between requested volume size and + actual size. Available options are: ebs - tries to resize EBS volume, pvc - + changes PVC definition, off - disables resize of the volumes. Default is "ebs". + * **secret_name_template** a template for the name of the database user secrets generated by the operator. `{username}` is replaced with name of the secret, `{cluster}` with diff --git a/manifests/configmap.yaml b/manifests/configmap.yaml index 963aea96b..5bee5d23f 100644 --- a/manifests/configmap.yaml +++ b/manifests/configmap.yaml @@ -42,6 +42,7 @@ data: enable_replica_load_balancer: "false" # enable_shm_volume: "true" # enable_sidecars: "true" + # enable_storage_resize: "ebs" # enable_team_superuser: "false" enable_teams_api: "false" # etcd_host: "" diff --git a/manifests/postgresql-operator-default-configuration.yaml b/manifests/postgresql-operator-default-configuration.yaml index ab6a23113..bf4c92969 100644 --- a/manifests/postgresql-operator-default-configuration.yaml +++ b/manifests/postgresql-operator-default-configuration.yaml @@ -38,6 +38,7 @@ configuration: enable_pod_antiaffinity: false enable_pod_disruption_budget: true enable_sidecars: true + enable_storage_resize: ebs # infrastructure_roles_secret_name: "postgresql-infrastructure-roles" # inherited_labels: # - application diff --git a/pkg/cluster/volumes.go b/pkg/cluster/volumes.go index b75a85859..473e3fb23 100644 --- a/pkg/cluster/volumes.go +++ b/pkg/cluster/volumes.go @@ -179,7 +179,7 @@ func (c *Cluster) resizeVolumes(newVolume acidv1.Volume, resizers []volumes.Volu c.logger.Debugf("successfully updated persistent volume %q", pv.Name) } if !compatible { - c.logger.Warningf("volume %q is incompatible with all available resizing providers", pv.Name) + c.logger.Warningf("volume %q is incompatible with all available resizing providers, consider switching enanble_storage_resize to pvc or off", pv.Name) totalIncompatible++ } } From dd2ff91002cb862521c8b9f94cf4d7c1dfae6fb1 Mon Sep 17 00:00:00 2001 From: Igor Yanchenko Date: Thu, 25 Jun 2020 10:16:00 +0200 Subject: [PATCH 06/17] enable_storage_resize renamed to volume_resize_mode, off by default --- charts/postgres-operator/values-crd.yaml | 4 +-- charts/postgres-operator/values.yaml | 4 +-- docs/reference/operator_parameters.md | 10 +++---- manifests/configmap.yaml | 2 +- manifests/operatorconfiguration.crd.yaml | 12 ++++---- ...gresql-operator-default-configuration.yaml | 2 +- pkg/apis/acid.zalan.do/v1/crds.go | 28 +++++++++---------- .../v1/operator_configuration_type.go | 2 +- pkg/cluster/sync.go | 6 ++-- pkg/controller/operator_config.go | 2 +- pkg/util/config/config.go | 2 +- 11 files changed, 37 insertions(+), 37 deletions(-) diff --git a/charts/postgres-operator/values-crd.yaml b/charts/postgres-operator/values-crd.yaml index a86806b7c..4cb79cea6 100644 --- a/charts/postgres-operator/values-crd.yaml +++ b/charts/postgres-operator/values-crd.yaml @@ -80,8 +80,6 @@ configKubernetes: enable_pod_disruption_budget: true # enables sidecar containers to run alongside Spilo in the same pod enable_sidecars: true - # storage resize strategy, available options are: ebs, pvc, off - enable_storage_resize: ebs # namespaced name of the secret containing infrastructure roles names and passwords # infrastructure_roles_secret_name: postgresql-infrastructure-roles @@ -126,6 +124,8 @@ configKubernetes: # whether the Spilo container should run in privileged mode spilo_privileged: false + # storage resize strategy, available options are: ebs, pvc, off + volume_resize_mode: off # operator watches for postgres objects in the given namespace watched_namespace: "*" # listen to all namespaces diff --git a/charts/postgres-operator/values.yaml b/charts/postgres-operator/values.yaml index a6a602b29..cceaf64be 100644 --- a/charts/postgres-operator/values.yaml +++ b/charts/postgres-operator/values.yaml @@ -74,8 +74,6 @@ configKubernetes: enable_pod_disruption_budget: "true" # enables sidecar containers to run alongside Spilo in the same pod enable_sidecars: "true" - # storage resize strategy, available options are: ebs, pvc, off - enable_storage_resize: ebs # namespaced name of the secret containing infrastructure roles names and passwords # infrastructure_roles_secret_name: postgresql-infrastructure-roles @@ -117,6 +115,8 @@ configKubernetes: # whether the Spilo container should run in privileged mode spilo_privileged: "false" + # storage resize strategy, available options are: ebs, pvc, off + volume_resize_mode: off # operator watches for postgres objects in the given namespace watched_namespace: "*" # listen to all namespaces diff --git a/docs/reference/operator_parameters.md b/docs/reference/operator_parameters.md index 42ff8b9a2..ecbc1315a 100644 --- a/docs/reference/operator_parameters.md +++ b/docs/reference/operator_parameters.md @@ -234,11 +234,6 @@ configuration they are grouped under the `kubernetes` key. to run alongside Spilo on the same pod. Globally defined sidecars are always enabled. Default is true. -* **enable_storage_resize** - defines how operator handels the difference between requested volume size and - actual size. Available options are: ebs - tries to resize EBS volume, pvc - - changes PVC definition, off - disables resize of the volumes. Default is "ebs". - * **secret_name_template** a template for the name of the database user secrets generated by the operator. `{username}` is replaced with name of the secret, `{cluster}` with @@ -338,6 +333,11 @@ configuration they are grouped under the `kubernetes` key. of stateful sets of PG clusters. The default is `ordered_ready`, the second possible value is `parallel`. +* **volume_resize_mode** + defines how operator handels the difference between requested volume size and + actual size. Available options are: ebs - tries to resize EBS volume, pvc - + changes PVC definition, off - disables resize of the volumes. Default is "off". + ## Kubernetes resource requests This group allows you to configure resource requests for the Postgres pods. diff --git a/manifests/configmap.yaml b/manifests/configmap.yaml index 5bee5d23f..9c6dedc09 100644 --- a/manifests/configmap.yaml +++ b/manifests/configmap.yaml @@ -42,7 +42,6 @@ data: enable_replica_load_balancer: "false" # enable_shm_volume: "true" # enable_sidecars: "true" - # enable_storage_resize: "ebs" # enable_team_superuser: "false" enable_teams_api: "false" # etcd_host: "" @@ -103,6 +102,7 @@ data: # team_api_role_configuration: "log_statement:all" # teams_api_url: http://fake-teams-api.default.svc.cluster.local # toleration: "" + # volume_resize_mode: "off" # wal_gs_bucket: "" # wal_s3_bucket: "" watched_namespace: "*" # listen to all namespaces diff --git a/manifests/operatorconfiguration.crd.yaml b/manifests/operatorconfiguration.crd.yaml index e2ad392c0..d23625ce5 100644 --- a/manifests/operatorconfiguration.crd.yaml +++ b/manifests/operatorconfiguration.crd.yaml @@ -123,12 +123,6 @@ spec: type: boolean enable_pod_disruption_budget: type: boolean - enable_storage_resize: - type: string - enum: - - "ebs" - - "pvc" - - "off" enable_sidecars: type: boolean infrastructure_roles_secret_name: @@ -178,6 +172,12 @@ spec: type: object additionalProperties: type: string + volume_resize_mode: + type: string + enum: + - "ebs" + - "pvc" + - "off" watched_namespace: type: string postgres_pod_resources: diff --git a/manifests/postgresql-operator-default-configuration.yaml b/manifests/postgresql-operator-default-configuration.yaml index bf4c92969..beb3e3a1c 100644 --- a/manifests/postgresql-operator-default-configuration.yaml +++ b/manifests/postgresql-operator-default-configuration.yaml @@ -38,7 +38,6 @@ configuration: enable_pod_antiaffinity: false enable_pod_disruption_budget: true enable_sidecars: true - enable_storage_resize: ebs # infrastructure_roles_secret_name: "postgresql-infrastructure-roles" # inherited_labels: # - application @@ -61,6 +60,7 @@ configuration: # spilo_fsgroup: 103 spilo_privileged: false # toleration: {} + volume_resize_mode: off # watched_namespace: "" postgres_pod_resources: default_cpu_limit: "1" diff --git a/pkg/apis/acid.zalan.do/v1/crds.go b/pkg/apis/acid.zalan.do/v1/crds.go index 693fca3fa..e3aec006a 100644 --- a/pkg/apis/acid.zalan.do/v1/crds.go +++ b/pkg/apis/acid.zalan.do/v1/crds.go @@ -905,20 +905,6 @@ var OperatorConfigCRDResourceValidation = apiextv1beta1.CustomResourceValidation "enable_pod_disruption_budget": { Type: "boolean", }, - "enable_storage_resize": { - Type: "string", - Enum: []apiextv1beta1.JSON{ - { - Raw: []byte(`"ebs"`), - }, - { - Raw: []byte(`"pvc"`), - }, - { - Raw: []byte(`"off"`), - }, - }, - }, "enable_sidecars": { Type: "boolean", }, @@ -1002,6 +988,20 @@ var OperatorConfigCRDResourceValidation = apiextv1beta1.CustomResourceValidation }, }, }, + "volume_resize_mode": { + Type: "string", + Enum: []apiextv1beta1.JSON{ + { + Raw: []byte(`"ebs"`), + }, + { + Raw: []byte(`"pvc"`), + }, + { + Raw: []byte(`"off"`), + }, + }, + }, "watched_namespace": { Type: "string", }, diff --git a/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go b/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go index c32bad776..7f5df72ed 100644 --- a/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go +++ b/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go @@ -53,7 +53,7 @@ type KubernetesMetaConfiguration struct { WatchedNamespace string `json:"watched_namespace,omitempty"` PDBNameFormat config.StringTemplate `json:"pdb_name_format,omitempty"` EnablePodDisruptionBudget *bool `json:"enable_pod_disruption_budget,omitempty"` - EnableStorageResize string `json:"enable_storage_resize,omitempty"` + VolumeResizeMode string `json:"volume_resize_mode,omitempty"` EnableInitContainers *bool `json:"enable_init_containers,omitempty"` EnableSidecars *bool `json:"enable_sidecars,omitempty"` SecretNameTemplate config.StringTemplate `json:"secret_name_template,omitempty"` diff --git a/pkg/cluster/sync.go b/pkg/cluster/sync.go index 3034824ab..6da6ef184 100644 --- a/pkg/cluster/sync.go +++ b/pkg/cluster/sync.go @@ -57,13 +57,13 @@ func (c *Cluster) Sync(newSpec *acidv1.Postgresql) error { return err } - if c.OpConfig.EnableStorageResize == "pvc" { + if c.OpConfig.VolumeResizeMode == "pvc" { c.logger.Debugf("syncing persistent volume claims") if err = c.syncVolumeClaims(); err != nil { err = fmt.Errorf("could not sync persistent volume claims: %v", err) return err } - } else if c.OpConfig.EnableStorageResize == "ebs" { + } else if c.OpConfig.VolumeResizeMode == "ebs" { // potentially enlarge volumes before changing the statefulset. By doing that // in this order we make sure the operator is not stuck waiting for a pod that // cannot start because it ran out of disk space. @@ -76,7 +76,7 @@ func (c *Cluster) Sync(newSpec *acidv1.Postgresql) error { return err } } else { - c.logger.Infof("Storage resize is disabled (enable_storage_resize is off). Skipping volume sync.") + c.logger.Infof("Storage resize is disabled (volume_resize_mode is off). Skipping volume sync.") } if err = c.enforceMinResourceLimits(&c.Spec); err != nil { diff --git a/pkg/controller/operator_config.go b/pkg/controller/operator_config.go index b7927ccba..72cf17ed8 100644 --- a/pkg/controller/operator_config.go +++ b/pkg/controller/operator_config.go @@ -65,7 +65,7 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur result.WatchedNamespace = fromCRD.Kubernetes.WatchedNamespace result.PDBNameFormat = fromCRD.Kubernetes.PDBNameFormat result.EnablePodDisruptionBudget = util.CoalesceBool(fromCRD.Kubernetes.EnablePodDisruptionBudget, util.True()) - result.EnableStorageResize = util.Coalesce(fromCRD.Kubernetes.EnableStorageResize, "ebs") + result.VolumeResizeMode = util.Coalesce(fromCRD.Kubernetes.VolumeResizeMode, "off") result.EnableInitContainers = util.CoalesceBool(fromCRD.Kubernetes.EnableInitContainers, util.True()) result.EnableSidecars = util.CoalesceBool(fromCRD.Kubernetes.EnableSidecars, util.True()) result.SecretNameTemplate = fromCRD.Kubernetes.SecretNameTemplate diff --git a/pkg/util/config/config.go b/pkg/util/config/config.go index 77609fa88..ac7db98cb 100644 --- a/pkg/util/config/config.go +++ b/pkg/util/config/config.go @@ -142,7 +142,7 @@ type Config struct { CustomPodAnnotations map[string]string `name:"custom_pod_annotations"` EnablePodAntiAffinity bool `name:"enable_pod_antiaffinity" default:"false"` PodAntiAffinityTopologyKey string `name:"pod_antiaffinity_topology_key" default:"kubernetes.io/hostname"` - EnableStorageResize string `name:"enable_storage_resize" default:"ebs"` + VolumeResizeMode string `name:"volume_resize_mode" default:"off"` // deprecated and kept for backward compatibility EnableLoadBalancer *bool `name:"enable_load_balancer"` MasterDNSNameFormat StringTemplate `name:"master_dns_name_format" default:"{cluster}.{team}.{hostedzone}"` From cb4b3db6e1cec423f4000a3c5d61e92e0428246c Mon Sep 17 00:00:00 2001 From: Igor Yanchenko Date: Thu, 25 Jun 2020 10:24:11 +0200 Subject: [PATCH 07/17] volume_resize_mode renamed to storage_resize_mode --- charts/postgres-operator/values-crd.yaml | 2 +- charts/postgres-operator/values.yaml | 2 +- docs/reference/operator_parameters.md | 2 +- manifests/configmap.yaml | 2 +- manifests/operatorconfiguration.crd.yaml | 10 +++++----- ...ostgresql-operator-default-configuration.yaml | 2 +- pkg/apis/acid.zalan.do/v1/crds.go | 16 ++++++++-------- .../v1/operator_configuration_type.go | 2 +- pkg/cluster/sync.go | 6 +++--- pkg/controller/operator_config.go | 2 +- pkg/util/config/config.go | 2 +- 11 files changed, 24 insertions(+), 24 deletions(-) diff --git a/charts/postgres-operator/values-crd.yaml b/charts/postgres-operator/values-crd.yaml index 4cb79cea6..80aa2f56e 100644 --- a/charts/postgres-operator/values-crd.yaml +++ b/charts/postgres-operator/values-crd.yaml @@ -125,7 +125,7 @@ configKubernetes: # whether the Spilo container should run in privileged mode spilo_privileged: false # storage resize strategy, available options are: ebs, pvc, off - volume_resize_mode: off + storage_resize_mode: off # operator watches for postgres objects in the given namespace watched_namespace: "*" # listen to all namespaces diff --git a/charts/postgres-operator/values.yaml b/charts/postgres-operator/values.yaml index cceaf64be..f0a670515 100644 --- a/charts/postgres-operator/values.yaml +++ b/charts/postgres-operator/values.yaml @@ -116,7 +116,7 @@ configKubernetes: # whether the Spilo container should run in privileged mode spilo_privileged: "false" # storage resize strategy, available options are: ebs, pvc, off - volume_resize_mode: off + storage_resize_mode: off # operator watches for postgres objects in the given namespace watched_namespace: "*" # listen to all namespaces diff --git a/docs/reference/operator_parameters.md b/docs/reference/operator_parameters.md index ecbc1315a..1e3a989d9 100644 --- a/docs/reference/operator_parameters.md +++ b/docs/reference/operator_parameters.md @@ -333,7 +333,7 @@ configuration they are grouped under the `kubernetes` key. of stateful sets of PG clusters. The default is `ordered_ready`, the second possible value is `parallel`. -* **volume_resize_mode** +* **storage_resize_mode** defines how operator handels the difference between requested volume size and actual size. Available options are: ebs - tries to resize EBS volume, pvc - changes PVC definition, off - disables resize of the volumes. Default is "off". diff --git a/manifests/configmap.yaml b/manifests/configmap.yaml index 9c6dedc09..d666b0383 100644 --- a/manifests/configmap.yaml +++ b/manifests/configmap.yaml @@ -97,12 +97,12 @@ data: # set_memory_request_to_limit: "false" # spilo_fsgroup: 103 spilo_privileged: "false" + # storage_resize_mode: "off" super_username: postgres # team_admin_role: "admin" # team_api_role_configuration: "log_statement:all" # teams_api_url: http://fake-teams-api.default.svc.cluster.local # toleration: "" - # volume_resize_mode: "off" # wal_gs_bucket: "" # wal_s3_bucket: "" watched_namespace: "*" # listen to all namespaces diff --git a/manifests/operatorconfiguration.crd.yaml b/manifests/operatorconfiguration.crd.yaml index d23625ce5..346eabb4a 100644 --- a/manifests/operatorconfiguration.crd.yaml +++ b/manifests/operatorconfiguration.crd.yaml @@ -168,16 +168,16 @@ spec: type: integer spilo_privileged: type: boolean - toleration: - type: object - additionalProperties: - type: string - volume_resize_mode: + storage_resize_mode: type: string enum: - "ebs" - "pvc" - "off" + toleration: + type: object + additionalProperties: + type: string watched_namespace: type: string postgres_pod_resources: diff --git a/manifests/postgresql-operator-default-configuration.yaml b/manifests/postgresql-operator-default-configuration.yaml index beb3e3a1c..1a593ab37 100644 --- a/manifests/postgresql-operator-default-configuration.yaml +++ b/manifests/postgresql-operator-default-configuration.yaml @@ -59,8 +59,8 @@ configuration: secret_name_template: "{username}.{cluster}.credentials.{tprkind}.{tprgroup}" # spilo_fsgroup: 103 spilo_privileged: false + storage_resize_mode: off # toleration: {} - volume_resize_mode: off # watched_namespace: "" postgres_pod_resources: default_cpu_limit: "1" diff --git a/pkg/apis/acid.zalan.do/v1/crds.go b/pkg/apis/acid.zalan.do/v1/crds.go index e3aec006a..8e68f3783 100644 --- a/pkg/apis/acid.zalan.do/v1/crds.go +++ b/pkg/apis/acid.zalan.do/v1/crds.go @@ -980,14 +980,6 @@ var OperatorConfigCRDResourceValidation = apiextv1beta1.CustomResourceValidation "spilo_privileged": { Type: "boolean", }, - "toleration": { - Type: "object", - AdditionalProperties: &apiextv1beta1.JSONSchemaPropsOrBool{ - Schema: &apiextv1beta1.JSONSchemaProps{ - Type: "string", - }, - }, - }, "volume_resize_mode": { Type: "string", Enum: []apiextv1beta1.JSON{ @@ -1002,6 +994,14 @@ var OperatorConfigCRDResourceValidation = apiextv1beta1.CustomResourceValidation }, }, }, + "toleration": { + Type: "object", + AdditionalProperties: &apiextv1beta1.JSONSchemaPropsOrBool{ + Schema: &apiextv1beta1.JSONSchemaProps{ + Type: "string", + }, + }, + }, "watched_namespace": { Type: "string", }, diff --git a/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go b/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go index 7f5df72ed..5ac5a4677 100644 --- a/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go +++ b/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go @@ -53,7 +53,7 @@ type KubernetesMetaConfiguration struct { WatchedNamespace string `json:"watched_namespace,omitempty"` PDBNameFormat config.StringTemplate `json:"pdb_name_format,omitempty"` EnablePodDisruptionBudget *bool `json:"enable_pod_disruption_budget,omitempty"` - VolumeResizeMode string `json:"volume_resize_mode,omitempty"` + StorageResizeMode string `json:"storage_resize_mode,omitempty"` EnableInitContainers *bool `json:"enable_init_containers,omitempty"` EnableSidecars *bool `json:"enable_sidecars,omitempty"` SecretNameTemplate config.StringTemplate `json:"secret_name_template,omitempty"` diff --git a/pkg/cluster/sync.go b/pkg/cluster/sync.go index 6da6ef184..80acb3d0e 100644 --- a/pkg/cluster/sync.go +++ b/pkg/cluster/sync.go @@ -57,13 +57,13 @@ func (c *Cluster) Sync(newSpec *acidv1.Postgresql) error { return err } - if c.OpConfig.VolumeResizeMode == "pvc" { + if c.OpConfig.StorageResizeMode == "pvc" { c.logger.Debugf("syncing persistent volume claims") if err = c.syncVolumeClaims(); err != nil { err = fmt.Errorf("could not sync persistent volume claims: %v", err) return err } - } else if c.OpConfig.VolumeResizeMode == "ebs" { + } else if c.OpConfig.StorageResizeMode == "ebs" { // potentially enlarge volumes before changing the statefulset. By doing that // in this order we make sure the operator is not stuck waiting for a pod that // cannot start because it ran out of disk space. @@ -76,7 +76,7 @@ func (c *Cluster) Sync(newSpec *acidv1.Postgresql) error { return err } } else { - c.logger.Infof("Storage resize is disabled (volume_resize_mode is off). Skipping volume sync.") + c.logger.Infof("Storage resize is disabled (storage_resize_mode is off). Skipping volume sync.") } if err = c.enforceMinResourceLimits(&c.Spec); err != nil { diff --git a/pkg/controller/operator_config.go b/pkg/controller/operator_config.go index 72cf17ed8..bcffc1de9 100644 --- a/pkg/controller/operator_config.go +++ b/pkg/controller/operator_config.go @@ -65,7 +65,7 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur result.WatchedNamespace = fromCRD.Kubernetes.WatchedNamespace result.PDBNameFormat = fromCRD.Kubernetes.PDBNameFormat result.EnablePodDisruptionBudget = util.CoalesceBool(fromCRD.Kubernetes.EnablePodDisruptionBudget, util.True()) - result.VolumeResizeMode = util.Coalesce(fromCRD.Kubernetes.VolumeResizeMode, "off") + result.StorageResizeMode = util.Coalesce(fromCRD.Kubernetes.StorageResizeMode, "off") result.EnableInitContainers = util.CoalesceBool(fromCRD.Kubernetes.EnableInitContainers, util.True()) result.EnableSidecars = util.CoalesceBool(fromCRD.Kubernetes.EnableSidecars, util.True()) result.SecretNameTemplate = fromCRD.Kubernetes.SecretNameTemplate diff --git a/pkg/util/config/config.go b/pkg/util/config/config.go index ac7db98cb..cb7710272 100644 --- a/pkg/util/config/config.go +++ b/pkg/util/config/config.go @@ -142,7 +142,7 @@ type Config struct { CustomPodAnnotations map[string]string `name:"custom_pod_annotations"` EnablePodAntiAffinity bool `name:"enable_pod_antiaffinity" default:"false"` PodAntiAffinityTopologyKey string `name:"pod_antiaffinity_topology_key" default:"kubernetes.io/hostname"` - VolumeResizeMode string `name:"volume_resize_mode" default:"off"` + StorageResizeMode string `name:"storage_resize_mode" default:"off"` // deprecated and kept for backward compatibility EnableLoadBalancer *bool `name:"enable_load_balancer"` MasterDNSNameFormat StringTemplate `name:"master_dns_name_format" default:"{cluster}.{team}.{hostedzone}"` From b8adb591b7c765cdac7f96d5489640eae16ad4f0 Mon Sep 17 00:00:00 2001 From: Felix Kunde Date: Thu, 25 Jun 2020 11:20:30 +0200 Subject: [PATCH 08/17] Update pkg/apis/acid.zalan.do/v1/crds.go --- pkg/apis/acid.zalan.do/v1/crds.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/apis/acid.zalan.do/v1/crds.go b/pkg/apis/acid.zalan.do/v1/crds.go index 8e68f3783..bc38d6dfd 100644 --- a/pkg/apis/acid.zalan.do/v1/crds.go +++ b/pkg/apis/acid.zalan.do/v1/crds.go @@ -980,7 +980,7 @@ var OperatorConfigCRDResourceValidation = apiextv1beta1.CustomResourceValidation "spilo_privileged": { Type: "boolean", }, - "volume_resize_mode": { + "storage_resize_mode": { Type: "string", Enum: []apiextv1beta1.JSON{ { From c346741175c551dd339cabba8abed0df2ee7c2ff Mon Sep 17 00:00:00 2001 From: Igor Yanchenko Date: Thu, 25 Jun 2020 12:03:25 +0200 Subject: [PATCH 09/17] pkg/cluster/volumes.go updated --- pkg/cluster/volumes.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/cluster/volumes.go b/pkg/cluster/volumes.go index 473e3fb23..d5c08c2e2 100644 --- a/pkg/cluster/volumes.go +++ b/pkg/cluster/volumes.go @@ -179,7 +179,7 @@ func (c *Cluster) resizeVolumes(newVolume acidv1.Volume, resizers []volumes.Volu c.logger.Debugf("successfully updated persistent volume %q", pv.Name) } if !compatible { - c.logger.Warningf("volume %q is incompatible with all available resizing providers, consider switching enanble_storage_resize to pvc or off", pv.Name) + c.logger.Warningf("volume %q is incompatible with all available resizing providers, consider switching storage_resize_mode to pvc or off", pv.Name) totalIncompatible++ } } From ddb582347a1b19f5b5c5ccc48ea2115f47dbc5ac Mon Sep 17 00:00:00 2001 From: Felix Kunde Date: Wed, 1 Jul 2020 10:23:09 +0200 Subject: [PATCH 10/17] Update docs/reference/operator_parameters.md --- docs/reference/operator_parameters.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/reference/operator_parameters.md b/docs/reference/operator_parameters.md index 1e3a989d9..1e660ff95 100644 --- a/docs/reference/operator_parameters.md +++ b/docs/reference/operator_parameters.md @@ -336,7 +336,8 @@ configuration they are grouped under the `kubernetes` key. * **storage_resize_mode** defines how operator handels the difference between requested volume size and actual size. Available options are: ebs - tries to resize EBS volume, pvc - - changes PVC definition, off - disables resize of the volumes. Default is "off". + changes PVC definition, off - disables resize of the volumes. Default is "ebs". + When using OpenShift please use on of the other options. ## Kubernetes resource requests From 2c81663bdeb73f3bf3f88328f09989feb93b0b92 Mon Sep 17 00:00:00 2001 From: Felix Kunde Date: Wed, 1 Jul 2020 10:23:43 +0200 Subject: [PATCH 11/17] Update manifests/postgresql-operator-default-configuration.yaml --- manifests/postgresql-operator-default-configuration.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/postgresql-operator-default-configuration.yaml b/manifests/postgresql-operator-default-configuration.yaml index 1a593ab37..cb7b1ed11 100644 --- a/manifests/postgresql-operator-default-configuration.yaml +++ b/manifests/postgresql-operator-default-configuration.yaml @@ -59,7 +59,7 @@ configuration: secret_name_template: "{username}.{cluster}.credentials.{tprkind}.{tprgroup}" # spilo_fsgroup: 103 spilo_privileged: false - storage_resize_mode: off + storage_resize_mode: ebs # toleration: {} # watched_namespace: "" postgres_pod_resources: From d7b6cca4dda47172d14754ac67e4e9784b25836d Mon Sep 17 00:00:00 2001 From: Felix Kunde Date: Wed, 1 Jul 2020 10:25:27 +0200 Subject: [PATCH 12/17] Update pkg/controller/operator_config.go --- pkg/controller/operator_config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/controller/operator_config.go b/pkg/controller/operator_config.go index bcffc1de9..a5a91dba7 100644 --- a/pkg/controller/operator_config.go +++ b/pkg/controller/operator_config.go @@ -65,7 +65,7 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur result.WatchedNamespace = fromCRD.Kubernetes.WatchedNamespace result.PDBNameFormat = fromCRD.Kubernetes.PDBNameFormat result.EnablePodDisruptionBudget = util.CoalesceBool(fromCRD.Kubernetes.EnablePodDisruptionBudget, util.True()) - result.StorageResizeMode = util.Coalesce(fromCRD.Kubernetes.StorageResizeMode, "off") + result.StorageResizeMode = util.Coalesce(fromCRD.Kubernetes.StorageResizeMode, "ebs") result.EnableInitContainers = util.CoalesceBool(fromCRD.Kubernetes.EnableInitContainers, util.True()) result.EnableSidecars = util.CoalesceBool(fromCRD.Kubernetes.EnableSidecars, util.True()) result.SecretNameTemplate = fromCRD.Kubernetes.SecretNameTemplate From 0a63bcca16c88722577942e1514a55b58a815ccd Mon Sep 17 00:00:00 2001 From: Felix Kunde Date: Wed, 1 Jul 2020 10:25:47 +0200 Subject: [PATCH 13/17] Update pkg/util/config/config.go --- pkg/util/config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/util/config/config.go b/pkg/util/config/config.go index cb7710272..bf1f5b70a 100644 --- a/pkg/util/config/config.go +++ b/pkg/util/config/config.go @@ -142,7 +142,7 @@ type Config struct { CustomPodAnnotations map[string]string `name:"custom_pod_annotations"` EnablePodAntiAffinity bool `name:"enable_pod_antiaffinity" default:"false"` PodAntiAffinityTopologyKey string `name:"pod_antiaffinity_topology_key" default:"kubernetes.io/hostname"` - StorageResizeMode string `name:"storage_resize_mode" default:"off"` + StorageResizeMode string `name:"storage_resize_mode" default:"ebs"` // deprecated and kept for backward compatibility EnableLoadBalancer *bool `name:"enable_load_balancer"` MasterDNSNameFormat StringTemplate `name:"master_dns_name_format" default:"{cluster}.{team}.{hostedzone}"` From 379129b5712a2089c55ab2391b8bd18cea0aaf0c Mon Sep 17 00:00:00 2001 From: Felix Kunde Date: Wed, 1 Jul 2020 10:26:12 +0200 Subject: [PATCH 14/17] Update charts/postgres-operator/values-crd.yaml --- charts/postgres-operator/values-crd.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/postgres-operator/values-crd.yaml b/charts/postgres-operator/values-crd.yaml index 80aa2f56e..db26e6d98 100644 --- a/charts/postgres-operator/values-crd.yaml +++ b/charts/postgres-operator/values-crd.yaml @@ -125,7 +125,7 @@ configKubernetes: # whether the Spilo container should run in privileged mode spilo_privileged: false # storage resize strategy, available options are: ebs, pvc, off - storage_resize_mode: off + storage_resize_mode: ebs # operator watches for postgres objects in the given namespace watched_namespace: "*" # listen to all namespaces From 8264fbee799f4f3abe61d4a90a6d2a80dd964acd Mon Sep 17 00:00:00 2001 From: Felix Kunde Date: Wed, 1 Jul 2020 10:26:32 +0200 Subject: [PATCH 15/17] Update charts/postgres-operator/values.yaml --- charts/postgres-operator/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/postgres-operator/values.yaml b/charts/postgres-operator/values.yaml index f0a670515..eb5c10b0e 100644 --- a/charts/postgres-operator/values.yaml +++ b/charts/postgres-operator/values.yaml @@ -116,7 +116,7 @@ configKubernetes: # whether the Spilo container should run in privileged mode spilo_privileged: "false" # storage resize strategy, available options are: ebs, pvc, off - storage_resize_mode: off + storage_resize_mode: ebs # operator watches for postgres objects in the given namespace watched_namespace: "*" # listen to all namespaces From 792dc889ba69d554e5b883b1bc2e800cbb2f93c7 Mon Sep 17 00:00:00 2001 From: Felix Kunde Date: Wed, 1 Jul 2020 10:27:11 +0200 Subject: [PATCH 16/17] Update docs/reference/operator_parameters.md --- docs/reference/operator_parameters.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/operator_parameters.md b/docs/reference/operator_parameters.md index 1e660ff95..7e5196d56 100644 --- a/docs/reference/operator_parameters.md +++ b/docs/reference/operator_parameters.md @@ -337,7 +337,7 @@ configuration they are grouped under the `kubernetes` key. defines how operator handels the difference between requested volume size and actual size. Available options are: ebs - tries to resize EBS volume, pvc - changes PVC definition, off - disables resize of the volumes. Default is "ebs". - When using OpenShift please use on of the other options. + When using OpenShift please use one of the other available options. ## Kubernetes resource requests From f7f6997d7e92fbe2897d3c155600e17dcf9e5f03 Mon Sep 17 00:00:00 2001 From: Igor Yanchenko Date: Wed, 1 Jul 2020 11:36:37 +0300 Subject: [PATCH 17/17] added logging if no changes required --- pkg/cluster/sync.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/cluster/sync.go b/pkg/cluster/sync.go index 80acb3d0e..b03b5d494 100644 --- a/pkg/cluster/sync.go +++ b/pkg/cluster/sync.go @@ -590,6 +590,7 @@ func (c *Cluster) syncVolumeClaims() error { return fmt.Errorf("could not compare size of the volume claims: %v", err) } if !act { + c.logger.Infof("volume claims don't require changes") return nil } if err := c.resizeVolumeClaims(c.Spec.Volume); err != nil {