From 22978eddf8b2bf31c0f2ee7763b88149b33abcd6 Mon Sep 17 00:00:00 2001 From: Felix Kunde Date: Thu, 30 Apr 2020 16:42:10 +0200 Subject: [PATCH] some final polishing --- .../crds/operatorconfigurations.yaml | 4 ++++ charts/postgres-operator/values-crd.yaml | 8 +++++--- charts/postgres-operator/values.yaml | 6 +++--- docs/reference/operator_parameters.md | 11 ++++++----- manifests/configmap.yaml | 2 +- manifests/operatorconfiguration.crd.yaml | 8 ++++---- ...postgresql-operator-default-configuration.yaml | 6 +++--- .../v1/operator_configuration_type.go | 3 +-- .../acid.zalan.do/v1/zz_generated.deepcopy.go | 15 +++++---------- pkg/controller/operator_config.go | 3 +-- pkg/util/config/config.go | 2 +- 11 files changed, 34 insertions(+), 34 deletions(-) diff --git a/charts/postgres-operator/crds/operatorconfigurations.yaml b/charts/postgres-operator/crds/operatorconfigurations.yaml index 71260bdb6..ffcef7b4a 100644 --- a/charts/postgres-operator/crds/operatorconfigurations.yaml +++ b/charts/postgres-operator/crds/operatorconfigurations.yaml @@ -117,6 +117,10 @@ spec: type: object additionalProperties: type: string + downscaler_annotations: + type: array + items: + type: string enable_init_containers: type: boolean enable_pod_antiaffinity: diff --git a/charts/postgres-operator/values-crd.yaml b/charts/postgres-operator/values-crd.yaml index 124360392..98a399c8b 100644 --- a/charts/postgres-operator/values-crd.yaml +++ b/charts/postgres-operator/values-crd.yaml @@ -55,9 +55,6 @@ configUsers: super_username: postgres configKubernetes: - # downscaler_annotations: - # - deployment-time - # - downscaler/* # default DNS domain of K8s cluster where operator is running cluster_domain: cluster.local # additional labels assigned to the cluster objects @@ -70,6 +67,11 @@ configKubernetes: # keya: valuea # keyb: valueb + # list of annotations propagated from cluster manifest to statefulset and deployment + # downscaler_annotations: + # - deployment-time + # - downscaler/* + # enables initContainers to run actions before Spilo is started enable_init_containers: true # toggles pod anti affinity on the Postgres pods diff --git a/charts/postgres-operator/values.yaml b/charts/postgres-operator/values.yaml index a48fd5d87..5578a5ed1 100644 --- a/charts/postgres-operator/values.yaml +++ b/charts/postgres-operator/values.yaml @@ -54,9 +54,6 @@ configUsers: super_username: postgres configKubernetes: - # downscaler_annotations: - # - deployment-time - # - downscaler/* # default DNS domain of K8s cluster where operator is running cluster_domain: cluster.local # additional labels assigned to the cluster objects @@ -66,6 +63,9 @@ configKubernetes: # annotations attached to each database pod # custom_pod_annotations: "keya:valuea,keyb:valueb" + # list of annotations propagated from cluster manifest to statefulset and deployment + # downscaler_annotations: "deployment-time,downscaler/*" + # enables initContainers to run actions before Spilo is started enable_init_containers: "true" # toggles pod anti affinity on the Postgres pods diff --git a/docs/reference/operator_parameters.md b/docs/reference/operator_parameters.md index cd4a487f5..a81cabfc4 100644 --- a/docs/reference/operator_parameters.md +++ b/docs/reference/operator_parameters.md @@ -151,11 +151,6 @@ Those are top-level keys, containing both leaf keys and groups. [operator deployment manually](../../manifests/postgres-operator.yaml#L20). The default is `false`. -* **downscaler_annotations** - An array of annotations from PostgresCRD that should be passed on to the statefulsets. - This also accepts the regular expression like downscaler/*, etc. - These annotations will also be passed to the connection-pooler deployments if any. - ## Postgres users Parameters describing Postgres users. In a CRD-configuration, they are grouped @@ -205,6 +200,12 @@ configuration they are grouped under the `kubernetes` key. of a database created by the operator. If the annotation key is also provided by the database definition, the database definition value is used. +* **downscaler_annotations** + An array of annotations that should be passed from Postgres CRD on to the + statefulset and, if exists, to the connection pooler deployment as well. + Regular expressions like `downscaler/*` etc. are also accepted. Can be used + with [kube-downscaler](https://github.com/hjacobs/kube-downscaler). + * **watched_namespace** The operator watches for Postgres objects in the given namespace. If not specified, the value is taken from the operator namespace. A special `*` diff --git a/manifests/configmap.yaml b/manifests/configmap.yaml index 87f1634f7..537055b18 100644 --- a/manifests/configmap.yaml +++ b/manifests/configmap.yaml @@ -30,6 +30,7 @@ data: # default_memory_limit: 500Mi # default_memory_request: 100Mi docker_image: registry.opensource.zalan.do/acid/spilo-cdp-12:1.6-p115 + # downscaler_annotations: "deployment-time,downscaler/*" # enable_admin_role_for_users: "true" # enable_crd_validation: "true" # enable_database_access: "true" @@ -94,7 +95,6 @@ data: # sidecar_docker_images: "" # set_memory_request_to_limit: "false" spilo_privileged: "false" - # downscaler_annotations: "deployment-time,downscaler/*" super_username: postgres # team_admin_role: "admin" # team_api_role_configuration: "log_statement:all" diff --git a/manifests/operatorconfiguration.crd.yaml b/manifests/operatorconfiguration.crd.yaml index 2f947b336..23b5ff0fc 100644 --- a/manifests/operatorconfiguration.crd.yaml +++ b/manifests/operatorconfiguration.crd.yaml @@ -81,10 +81,6 @@ spec: kubernetes: type: object properties: - # downscaler_annotations: - # type: array - # items: - # type: string cluster_domain: type: string cluster_labels: @@ -97,6 +93,10 @@ spec: type: object additionalProperties: type: string + downscaler_annotations: + type: array + items: + type: string enable_init_containers: type: boolean enable_pod_antiaffinity: diff --git a/manifests/postgresql-operator-default-configuration.yaml b/manifests/postgresql-operator-default-configuration.yaml index 36bfbeefc..9ae1b3b26 100644 --- a/manifests/postgresql-operator-default-configuration.yaml +++ b/manifests/postgresql-operator-default-configuration.yaml @@ -24,9 +24,6 @@ configuration: replication_username: standby super_username: postgres kubernetes: - # downscaler_annotations: - # - deployment-time - # - downscaler/* cluster_domain: cluster.local cluster_labels: application: spilo @@ -34,6 +31,9 @@ configuration: # custom_pod_annotations: # keya: valuea # keyb: valueb + # downscaler_annotations: + # - deployment-time + # - downscaler/* enable_init_containers: true enable_pod_antiaffinity: false enable_pod_disruption_budget: true 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 fe14a7702..d3a9f6ec2 100644 --- a/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go +++ b/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go @@ -62,6 +62,7 @@ type KubernetesMetaConfiguration struct { PodRoleLabel string `json:"pod_role_label,omitempty"` ClusterLabels map[string]string `json:"cluster_labels,omitempty"` InheritedLabels []string `json:"inherited_labels,omitempty"` + DownscalerAnnotations []string `json:"downscaler_annotations,omitempty"` ClusterNameLabel string `json:"cluster_name_label,omitempty"` NodeReadinessLabel map[string]string `json:"node_readiness_label,omitempty"` CustomPodAnnotations map[string]string `json:"custom_pod_annotations,omitempty"` @@ -73,7 +74,6 @@ type KubernetesMetaConfiguration struct { EnablePodAntiAffinity bool `json:"enable_pod_antiaffinity,omitempty"` PodAntiAffinityTopologyKey string `json:"pod_antiaffinity_topology_key,omitempty"` PodManagementPolicy string `json:"pod_management_policy,omitempty"` - DownscalerAnnotations []string `json:"downscaler_annotations,omitempty"` } // PostgresPodResourcesDefaults defines the spec of default resources @@ -210,7 +210,6 @@ type OperatorConfigurationData struct { Scalyr ScalyrConfiguration `json:"scalyr"` LogicalBackup OperatorLogicalBackupConfiguration `json:"logical_backup"` ConnectionPooler ConnectionPoolerConfiguration `json:"connection_pooler"` - DownscalerAnnotations []string `json:"downscaler_annotations,omitempty"` } //Duration shortens this frequently used name diff --git a/pkg/apis/acid.zalan.do/v1/zz_generated.deepcopy.go b/pkg/apis/acid.zalan.do/v1/zz_generated.deepcopy.go index 0f1962f07..5879c9b73 100644 --- a/pkg/apis/acid.zalan.do/v1/zz_generated.deepcopy.go +++ b/pkg/apis/acid.zalan.do/v1/zz_generated.deepcopy.go @@ -180,6 +180,11 @@ func (in *KubernetesMetaConfiguration) DeepCopyInto(out *KubernetesMetaConfigura *out = make([]string, len(*in)) copy(*out, *in) } + if in.DownscalerAnnotations != nil { + in, out := &in.DownscalerAnnotations, &out.DownscalerAnnotations + *out = make([]string, len(*in)) + copy(*out, *in) + } if in.NodeReadinessLabel != nil { in, out := &in.NodeReadinessLabel, &out.NodeReadinessLabel *out = make(map[string]string, len(*in)) @@ -202,11 +207,6 @@ func (in *KubernetesMetaConfiguration) DeepCopyInto(out *KubernetesMetaConfigura } } out.PodEnvironmentConfigMap = in.PodEnvironmentConfigMap - if in.DownscalerAnnotations != nil { - in, out := &in.DownscalerAnnotations, &out.DownscalerAnnotations - *out = make([]string, len(*in)) - copy(*out, *in) - } return } @@ -343,11 +343,6 @@ func (in *OperatorConfigurationData) DeepCopyInto(out *OperatorConfigurationData out.Scalyr = in.Scalyr out.LogicalBackup = in.LogicalBackup in.ConnectionPooler.DeepCopyInto(&out.ConnectionPooler) - if in.DownscalerAnnotations != nil { - in, out := &in.DownscalerAnnotations, &out.DownscalerAnnotations - *out = make([]string, len(*in)) - copy(*out, *in) - } return } diff --git a/pkg/controller/operator_config.go b/pkg/controller/operator_config.go index 3ad967f9c..4eed44924 100644 --- a/pkg/controller/operator_config.go +++ b/pkg/controller/operator_config.go @@ -48,8 +48,6 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur result.SidecarImages = fromCRD.SidecarImages result.SidecarContainers = fromCRD.SidecarContainers - result.DownscalerAnnotations = fromCRD.Kubernetes.DownscalerAnnotations - // user config result.SuperUsername = fromCRD.PostgresUsersConfiguration.SuperUsername result.ReplicationUsername = fromCRD.PostgresUsersConfiguration.ReplicationUsername @@ -75,6 +73,7 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur result.PodRoleLabel = fromCRD.Kubernetes.PodRoleLabel result.ClusterLabels = fromCRD.Kubernetes.ClusterLabels result.InheritedLabels = fromCRD.Kubernetes.InheritedLabels + result.DownscalerAnnotations = fromCRD.Kubernetes.DownscalerAnnotations result.ClusterNameLabel = fromCRD.Kubernetes.ClusterNameLabel result.NodeReadinessLabel = fromCRD.Kubernetes.NodeReadinessLabel result.PodPriorityClassName = fromCRD.Kubernetes.PodPriorityClassName diff --git a/pkg/util/config/config.go b/pkg/util/config/config.go index 3165cab78..d5c4b6671 100644 --- a/pkg/util/config/config.go +++ b/pkg/util/config/config.go @@ -34,6 +34,7 @@ type Resources struct { SpiloPrivileged bool `name:"spilo_privileged" default:"false"` ClusterLabels map[string]string `name:"cluster_labels" default:"application:spilo"` InheritedLabels []string `name:"inherited_labels" default:""` + DownscalerAnnotations []string `name:"downscaler_annotations"` ClusterNameLabel string `name:"cluster_name_label" default:"cluster-name"` PodRoleLabel string `name:"pod_role_label" default:"spilo-role"` PodToleration map[string]string `name:"toleration" default:""` @@ -137,7 +138,6 @@ type Config struct { EnableReplicaLoadBalancer bool `name:"enable_replica_load_balancer" default:"false"` CustomServiceAnnotations map[string]string `name:"custom_service_annotations"` CustomPodAnnotations map[string]string `name:"custom_pod_annotations"` - DownscalerAnnotations []string `name:"downscaler_annotations"` EnablePodAntiAffinity bool `name:"enable_pod_antiaffinity" default:"false"` PodAntiAffinityTopologyKey string `name:"pod_antiaffinity_topology_key" default:"kubernetes.io/hostname"` // deprecated and kept for backward compatibility