Propagate annotations to the StatefulSet (#932)

* Initial commit

* Corrections

- set the type of the new  configuration parameter to be array of
  strings
- propagate the annotations to statefulset at sync

* Enable regular expression matching

* Improvements

-handle rollingUpdate flag
-modularize code
-rename config parameter name

* fix merge error

* Pass annotations to connection pooler deployment

* update code-gen

* Add documentation and update manifests

* add e2e test and introduce option in configmap

* fix service annotations test

* Add unit test

* fix e2e tests

* better key lookup of annotations tests

* add debug message for annotation tests

* Fix typos

* minor fix for looping

* Handle update path and renaming

- handle the update path to update sts and connection pooler deployment.
  This way no need to wait for sync
- rename the parameter to downscaler_annotations
- handle other review comments

* another try to fix python loops

* Avoid unneccessary update events

* Update manifests

* some final polishing

* fix cluster_test after polishing

Co-authored-by: Rafia Sabih <rafia.sabih@zalando.de>
Co-authored-by: Felix Kunde <felix-kunde@gmx.de>
This commit is contained in:
Rafia Sabih
2020-05-04 14:46:56 +02:00
committed by GitHub
co-authored by Rafia Sabih Felix Kunde
parent be208b61f1
commit d52296c323
20 changed files with 205 additions and 31 deletions
+21 -13
View File
@@ -21,48 +21,48 @@ const (
// PostgresCRDResourceColumns definition of AdditionalPrinterColumns for postgresql CRD
var PostgresCRDResourceColumns = []apiextv1beta1.CustomResourceColumnDefinition{
apiextv1beta1.CustomResourceColumnDefinition{
{
Name: "Team",
Type: "string",
Description: "Team responsible for Postgres cluster",
JSONPath: ".spec.teamId",
},
apiextv1beta1.CustomResourceColumnDefinition{
{
Name: "Version",
Type: "string",
Description: "PostgreSQL version",
JSONPath: ".spec.postgresql.version",
},
apiextv1beta1.CustomResourceColumnDefinition{
{
Name: "Pods",
Type: "integer",
Description: "Number of Pods per Postgres cluster",
JSONPath: ".spec.numberOfInstances",
},
apiextv1beta1.CustomResourceColumnDefinition{
{
Name: "Volume",
Type: "string",
Description: "Size of the bound volume",
JSONPath: ".spec.volume.size",
},
apiextv1beta1.CustomResourceColumnDefinition{
{
Name: "CPU-Request",
Type: "string",
Description: "Requested CPU for Postgres containers",
JSONPath: ".spec.resources.requests.cpu",
},
apiextv1beta1.CustomResourceColumnDefinition{
{
Name: "Memory-Request",
Type: "string",
Description: "Requested memory for Postgres containers",
JSONPath: ".spec.resources.requests.memory",
},
apiextv1beta1.CustomResourceColumnDefinition{
{
Name: "Age",
Type: "date",
JSONPath: ".metadata.creationTimestamp",
},
apiextv1beta1.CustomResourceColumnDefinition{
{
Name: "Status",
Type: "string",
Description: "Current sync status of postgresql resource",
@@ -72,31 +72,31 @@ var PostgresCRDResourceColumns = []apiextv1beta1.CustomResourceColumnDefinition{
// OperatorConfigCRDResourceColumns definition of AdditionalPrinterColumns for OperatorConfiguration CRD
var OperatorConfigCRDResourceColumns = []apiextv1beta1.CustomResourceColumnDefinition{
apiextv1beta1.CustomResourceColumnDefinition{
{
Name: "Image",
Type: "string",
Description: "Spilo image to be used for Pods",
JSONPath: ".configuration.docker_image",
},
apiextv1beta1.CustomResourceColumnDefinition{
{
Name: "Cluster-Label",
Type: "string",
Description: "Label for K8s resources created by operator",
JSONPath: ".configuration.kubernetes.cluster_name_label",
},
apiextv1beta1.CustomResourceColumnDefinition{
{
Name: "Service-Account",
Type: "string",
Description: "Name of service account to be used",
JSONPath: ".configuration.kubernetes.pod_service_account_name",
},
apiextv1beta1.CustomResourceColumnDefinition{
{
Name: "Min-Instances",
Type: "integer",
Description: "Minimum number of instances per Postgres cluster",
JSONPath: ".configuration.min_instances",
},
apiextv1beta1.CustomResourceColumnDefinition{
{
Name: "Age",
Type: "date",
JSONPath: ".metadata.creationTimestamp",
@@ -888,6 +888,14 @@ var OperatorConfigCRDResourceValidation = apiextv1beta1.CustomResourceValidation
},
},
},
"downscaler_annotations": {
Type: "array",
Items: &apiextv1beta1.JSONSchemaPropsOrArray{
Schema: &apiextv1beta1.JSONSchemaProps{
Type: "string",
},
},
},
"enable_init_containers": {
Type: "boolean",
},
@@ -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"`
@@ -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))