From 983a4e45b55119f8bca824fb8850f715be94a650 Mon Sep 17 00:00:00 2001 From: Felix Kunde Date: Mon, 4 Nov 2019 11:44:23 +0100 Subject: [PATCH] remove scalyr sidecar --- .../templates/operatorconfiguration.yaml | 2 - charts/postgres-operator/values-crd.yaml | 17 ------- docs/diagrams/pod.tex | 12 ++++- .../reference/command_line_and_environment.md | 10 ++-- docs/reference/operator_parameters.md | 33 ++----------- ...gresql-operator-default-configuration.yaml | 8 --- .../v1/operator_configuration_type.go | 12 ----- .../acid.zalan.do/v1/zz_generated.deepcopy.go | 17 ------- pkg/cluster/k8sres.go | 49 ------------------- pkg/controller/controller.go | 15 +----- pkg/controller/operator_config.go | 9 ---- pkg/util/config/config.go | 12 ----- 12 files changed, 17 insertions(+), 179 deletions(-) diff --git a/charts/postgres-operator/templates/operatorconfiguration.yaml b/charts/postgres-operator/templates/operatorconfiguration.yaml index c6e9f78b7..d981b8bce 100644 --- a/charts/postgres-operator/templates/operatorconfiguration.yaml +++ b/charts/postgres-operator/templates/operatorconfiguration.yaml @@ -32,6 +32,4 @@ configuration: {{ toYaml .Values.configTeamsApi | indent 4 }} logging_rest_api: {{ toYaml .Values.configLoggingRestApi | indent 4 }} - scalyr: -{{ toYaml .Values.configScalyr | indent 4 }} {{- end }} diff --git a/charts/postgres-operator/values-crd.yaml b/charts/postgres-operator/values-crd.yaml index 2728b245c..529d20e3d 100644 --- a/charts/postgres-operator/values-crd.yaml +++ b/charts/postgres-operator/values-crd.yaml @@ -217,23 +217,6 @@ configTeamsApi: # URL of the Teams API service # teams_api_url: http://fake-teams-api.default.svc.cluster.local -# Scalyr is a log management tool that Zalando uses as a sidecar -scalyr: - # API key for the Scalyr sidecar - # scalyr_api_key: "" - - # Docker image for the Scalyr sidecar - # scalyr_image: "" - - # CPU limit value for the Scalyr sidecar - scalyr_cpu_limit: "1" - # CPU rquest value for the Scalyr sidecar - scalyr_cpu_request: 100m - # Memory limit value for the Scalyr sidecar - scalyr_memory_limit: 1Gi - # Memory request value for the Scalyr sidecar - scalyr_memory_request: 50Mi - rbac: # Specifies whether RBAC resources should be created create: true diff --git a/docs/diagrams/pod.tex b/docs/diagrams/pod.tex index 291384642..8f89f3c9d 100644 --- a/docs/diagrams/pod.tex +++ b/docs/diagrams/pod.tex @@ -24,6 +24,7 @@ component/.style={draw,solid,thick,rounded corners,fill=yellow!20,inner sep=.3cm, blur shadow={shadow blur steps=5,shadow blur extra rounding=1.3pt}}, border/.style={draw,dashed,rounded corners,fill=gray!20,inner sep=.3cm, blur shadow={shadow blur steps=5,shadow blur extra rounding=1.3pt}}, volume/.style={draw,solid,thick,rounded corners,fill=blue!20, inner sep=.3cm, blur shadow={shadow blur steps=5,shadow blur extra rounding=1.3pt}}, + initcontainer/.style={draw,solid,thick,rounded corners,fill=blue!20, inner sep=.3cm, blur shadow={shadow blur steps=5,shadow blur extra rounding=1.3pt}}, sidecar/.style={draw,solid,thick,rounded corners,fill=blue!20, inner sep=.3cm, blur shadow={shadow blur steps=5,shadow blur extra rounding=1.3pt}}, k8s-label/.style={draw,solid,thick,rounded corners,fill=blue!20, minimum width=1.5cm, inner sep=.3cm, blur shadow={shadow blur steps=5,shadow blur extra rounding=1.3pt}}, affinity/.style={draw,solid,thick,rounded corners,fill=blue!20, minimum width=2cm, inner sep=.3cm, blur shadow={shadow blur steps=5,shadow blur extra rounding=1.3pt}}, @@ -60,7 +61,14 @@ fit=(data-volume)(shm-volume)(tokens-volume)(volumes-label) ] (volumes) {}; \& \node[component] (spilo) {Spilo}; \& - \node[sidecar] (scalyr) {Scalyr}; \& \\ \& + \path + node[initcontainer] (custom-initcontainer1) {User defined} + node[label, right=.25cm of custom-initcontainer1] (initcontainers-middle) {} + node[initcontainer, right=.25cm of initcontainers-middle] (custom-initcontainer2) {User defined} + node[label, below of=initcontainers-middle] (initcontainers-label) {Custom initcontainers} + node[border, behind path, + fit=(custom-initcontainer1)(custom-initcontainer2)(initcontainers-label) + ] (initcontainers) {}; \& \path node[component] (patroni) {Patroni} node[component, below=.25cm of patroni] (postgres) {PostgreSQL} @@ -82,7 +90,7 @@ \draw[to] (pod) to [bend left=25] (volumes); \draw[to] (pod) to [bend left=25] (k8s-labels); \draw[to] (pod) to [bend right=25] (affinity); - \draw[to] (pod) to [bend right=25] (scalyr); + \draw[to] (pod) to [bend right=25] (initcontainers); \draw[to] (pod) to [bend right=25] (sidecars); \draw[to] (pod) -- node[midway,above] {} node[midway,below] {} (spilo); \draw[to] (spilo) -- node[midway,above] {} node[midway,below] {} (spilo-components); diff --git a/docs/reference/command_line_and_environment.md b/docs/reference/command_line_and_environment.md index ec5da5ceb..c756f791b 100644 --- a/docs/reference/command_line_and_environment.md +++ b/docs/reference/command_line_and_environment.md @@ -41,13 +41,9 @@ The following environment variables are accepted by the operator: operator itself. * **WATCHED_NAMESPACE** - the name of the namespace the operator watches. Special '*' character denotes - all namespaces. Empty value defaults to the operator namespace. Overrides the - `watched_namespace` operator parameter. - -* **SCALYR_API_KEY** - the value of the Scalyr API key to supply to the pods. Overrides the - `scalyr_api_key` operator parameter. + the name of the namespace the operator watches. Special **'*'** character + denotes all namespaces. Empty value defaults to the operator namespace. + Overrides the `watched_namespace` operator parameter. * **CRD_READY_WAIT_TIMEOUT** defines the timeout for the complete `postgresql` CRD creation. When not set diff --git a/docs/reference/operator_parameters.md b/docs/reference/operator_parameters.md index 3e21340d5..ab74e9b96 100644 --- a/docs/reference/operator_parameters.md +++ b/docs/reference/operator_parameters.md @@ -120,9 +120,9 @@ Those are top-level keys, containing both leaf keys and groups. value is also increased). This prevents certain cases of memory overcommitment at the cost of overprovisioning memory and potential scheduling problems for containers with high memory limits due to the lack of memory on Kubernetes - cluster nodes. This affects all containers created by the operator (Postgres, - Scalyr sidecar, and other sidecars); to set resources for the operator's own - container, change the [operator deployment manually](../manifests/postgres-operator.yaml#L20). + cluster nodes. This affects all containers created by the operator incl. + sidecars); to set resources for the operator's own container, change the + [operator deployment manually](../manifests/postgres-operator.yaml#L20). The default is `false`. ## Postgres users @@ -523,30 +523,3 @@ configuration they are grouped under the `logging_rest_api` key. * **cluster_history_entries** number of entries in the cluster history ring buffer. The default is `1000`. - -## Scalyr options - -Those parameters define the resource requests/limits and properties of the -scalyr sidecar. In the CRD-based configuration they are grouped under the -`scalyr` key. - -* **scalyr_api_key** - API key for the Scalyr sidecar. The default is empty. - -* **scalyr_image** - Docker image for the Scalyr sidecar. The default is empty. - -* **scalyr_server_url** - server URL for the Scalyr sidecar. The default is `https://upload.eu.scalyr.com`. - -* **scalyr_cpu_request** - CPU request value for the Scalyr sidecar. The default is `100m`. - -* **scalyr_memory_request** - Memory request value for the Scalyr sidecar. The default is `50Mi`. - -* **scalyr_cpu_limit** - CPU limit value for the Scalyr sidecar. The default is `1`. - -* **scalyr_memory_limit** - Memory limit value for the Scalyr sidecar. The default is `1Gi`. diff --git a/manifests/postgresql-operator-default-configuration.yaml b/manifests/postgresql-operator-default-configuration.yaml index ad4d028c3..8ea03c7b3 100644 --- a/manifests/postgresql-operator-default-configuration.yaml +++ b/manifests/postgresql-operator-default-configuration.yaml @@ -94,11 +94,3 @@ configuration: api_port: 8008 cluster_history_entries: 1000 ring_log_lines: 100 - scalyr: - # scalyr_api_key: "" - scalyr_cpu_limit: "1" - scalyr_cpu_request: 100m - # scalyr_image: "" - scalyr_memory_limit: 1Gi - scalyr_memory_request: 50Mi - # scalyr_server_url: "" 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 6f1c8d59c..71295b6bc 100644 --- a/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go +++ b/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go @@ -136,17 +136,6 @@ type LoggingRESTAPIConfiguration struct { ClusterHistoryEntries int `json:"cluster_history_entries,omitempty"` } -// ScalyrConfiguration defines the configuration for ScalyrAPI -type ScalyrConfiguration struct { - ScalyrAPIKey string `json:"scalyr_api_key,omitempty"` - ScalyrImage string `json:"scalyr_image,omitempty"` - ScalyrServerURL string `json:"scalyr_server_url,omitempty"` - ScalyrCPURequest string `json:"scalyr_cpu_request,omitempty"` - ScalyrMemoryRequest string `json:"scalyr_memory_request,omitempty"` - ScalyrCPULimit string `json:"scalyr_cpu_limit,omitempty"` - ScalyrMemoryLimit string `json:"scalyr_memory_limit,omitempty"` -} - // OperatorConfigurationData defines the operation config type OperatorConfigurationData struct { EtcdHost string `json:"etcd_host,omitempty"` @@ -168,7 +157,6 @@ type OperatorConfigurationData struct { OperatorDebug OperatorDebugConfiguration `json:"debug"` TeamsAPI TeamsAPIConfiguration `json:"teams_api"` LoggingRESTAPI LoggingRESTAPIConfiguration `json:"logging_rest_api"` - Scalyr ScalyrConfiguration `json:"scalyr"` LogicalBackup OperatorLogicalBackupConfiguration `json:"logical_backup"` } 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 8e3411219..7a3f6ea32 100644 --- a/pkg/apis/acid.zalan.do/v1/zz_generated.deepcopy.go +++ b/pkg/apis/acid.zalan.do/v1/zz_generated.deepcopy.go @@ -230,7 +230,6 @@ func (in *OperatorConfigurationData) DeepCopyInto(out *OperatorConfigurationData out.OperatorDebug = in.OperatorDebug in.TeamsAPI.DeepCopyInto(&out.TeamsAPI) out.LoggingRESTAPI = in.LoggingRESTAPI - out.Scalyr = in.Scalyr out.LogicalBackup = in.LogicalBackup return } @@ -683,22 +682,6 @@ func (in *Resources) DeepCopy() *Resources { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ScalyrConfiguration) DeepCopyInto(out *ScalyrConfiguration) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ScalyrConfiguration. -func (in *ScalyrConfiguration) DeepCopy() *ScalyrConfiguration { - if in == nil { - return nil - } - out := new(ScalyrConfiguration) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Sidecar) DeepCopyInto(out *Sidecar) { *out = *in diff --git a/pkg/cluster/k8sres.go b/pkg/cluster/k8sres.go index 78d128387..453d580af 100644 --- a/pkg/cluster/k8sres.go +++ b/pkg/cluster/k8sres.go @@ -745,9 +745,6 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*appsv1.Statef } - // controller adjusts the Scalyr sidecar request at operator startup - // as this sidecar is managed separately - // adjust sidecar containers defined for that particular cluster for _, sidecar := range spec.Sidecars { @@ -849,23 +846,6 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*appsv1.Statef // resolve conflicts between operator-global and per-cluster sidecars sideCars := c.mergeSidecars(spec.Sidecars) - resourceRequirementsScalyrSidecar := makeResources( - c.OpConfig.ScalyrCPURequest, - c.OpConfig.ScalyrMemoryRequest, - c.OpConfig.ScalyrCPULimit, - c.OpConfig.ScalyrMemoryLimit, - ) - - // generate scalyr sidecar container - if scalyrSidecar := - generateScalyrSidecarSpec(c.Name, - c.OpConfig.ScalyrAPIKey, - c.OpConfig.ScalyrServerURL, - c.OpConfig.ScalyrImage, - &resourceRequirementsScalyrSidecar, c.logger); scalyrSidecar != nil { - sideCars = append(sideCars, *scalyrSidecar) - } - // generate sidecar containers if sidecarContainers, err = generateSidecarContainers(sideCars, volumeMounts, defaultResources, c.OpConfig.SuperUsername, c.credentialSecretName(c.OpConfig.SuperUsername), c.logger); err != nil { @@ -949,35 +929,6 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*appsv1.Statef return statefulSet, nil } -func generateScalyrSidecarSpec(clusterName, APIKey, serverURL, dockerImage string, - containerResources *acidv1.Resources, logger *logrus.Entry) *acidv1.Sidecar { - if APIKey == "" || dockerImage == "" { - if APIKey == "" && dockerImage != "" { - logger.Warning("Not running Scalyr sidecar: SCALYR_API_KEY must be defined") - } - return nil - } - scalarSpec := &acidv1.Sidecar{ - Name: "scalyr-sidecar", - DockerImage: dockerImage, - Env: []v1.EnvVar{ - { - Name: "SCALYR_API_KEY", - Value: APIKey, - }, - { - Name: "SCALYR_SERVER_HOST", - Value: clusterName, - }, - }, - Resources: *containerResources, - } - if serverURL != "" { - scalarSpec.Env = append(scalarSpec.Env, v1.EnvVar{Name: "SCALYR_SERVER_URL", Value: serverURL}) - } - return scalarSpec -} - // mergeSidecar merges globally-defined sidecars with those defined in the cluster manifest func (c *Cluster) mergeSidecars(sidecars []acidv1.Sidecar) []acidv1.Sidecar { globalSidecarsToSkip := map[string]bool{} diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index 9162ce27d..372e09ab0 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -6,7 +6,7 @@ import ( "sync" "github.com/sirupsen/logrus" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" rbacv1beta1 "k8s.io/api/rbac/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" @@ -120,15 +120,6 @@ func (c *Controller) initOperatorConfig() { c.opConfig.DefaultMemoryRequest = c.opConfig.DefaultMemoryLimit } - isSmaller, err = util.RequestIsSmallerThanLimit(c.opConfig.ScalyrMemoryRequest, c.opConfig.ScalyrMemoryLimit) - if err != nil { - panic(err) - } - if isSmaller { - c.logger.Warningf("The memory request of %v for the Scalyr sidecar container is increased to match the memory limit of %v.", c.opConfig.ScalyrMemoryRequest, c.opConfig.ScalyrMemoryLimit) - c.opConfig.ScalyrMemoryRequest = c.opConfig.ScalyrMemoryLimit - } - // generateStatefulSet adjusts values for individual Postgres clusters } @@ -143,10 +134,6 @@ func (c *Controller) modifyConfigFromEnvironment() { if c.config.NoTeamsAPI { c.opConfig.EnableTeamsAPI = false } - scalyrAPIKey := os.Getenv("SCALYR_API_KEY") - if scalyrAPIKey != "" { - c.opConfig.ScalyrAPIKey = scalyrAPIKey - } } // warningOnDeprecatedParameters emits warnings upon finding deprecated parmaters diff --git a/pkg/controller/operator_config.go b/pkg/controller/operator_config.go index 9da4bbaf8..ce72974b6 100644 --- a/pkg/controller/operator_config.go +++ b/pkg/controller/operator_config.go @@ -122,14 +122,5 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur result.RingLogLines = fromCRD.LoggingRESTAPI.RingLogLines result.ClusterHistoryEntries = fromCRD.LoggingRESTAPI.ClusterHistoryEntries - // Scalyr config - result.ScalyrAPIKey = fromCRD.Scalyr.ScalyrAPIKey - result.ScalyrImage = fromCRD.Scalyr.ScalyrImage - result.ScalyrServerURL = fromCRD.Scalyr.ScalyrServerURL - result.ScalyrCPURequest = fromCRD.Scalyr.ScalyrCPURequest - result.ScalyrMemoryRequest = fromCRD.Scalyr.ScalyrMemoryRequest - result.ScalyrCPULimit = fromCRD.Scalyr.ScalyrCPULimit - result.ScalyrMemoryLimit = fromCRD.Scalyr.ScalyrMemoryLimit - return result } diff --git a/pkg/util/config/config.go b/pkg/util/config/config.go index 5dd25d401..8cf1ed0ff 100644 --- a/pkg/util/config/config.go +++ b/pkg/util/config/config.go @@ -57,17 +57,6 @@ type Auth struct { ReplicationUsername string `name:"replication_username" default:"standby"` } -// Scalyr holds the configuration for the Scalyr Agent sidecar for log shipping: -type Scalyr struct { - ScalyrAPIKey string `name:"scalyr_api_key" default:""` - ScalyrImage string `name:"scalyr_image" default:""` - ScalyrServerURL string `name:"scalyr_server_url" default:"https://upload.eu.scalyr.com"` - ScalyrCPURequest string `name:"scalyr_cpu_request" default:"100m"` - ScalyrMemoryRequest string `name:"scalyr_memory_request" default:"50Mi"` - ScalyrCPULimit string `name:"scalyr_cpu_limit" default:"1"` - ScalyrMemoryLimit string `name:"scalyr_memory_limit" default:"1Gi"` -} - // LogicalBackup type LogicalBackup struct { LogicalBackupSchedule string `name:"logical_backup_schedule" default:"30 00 * * *"` @@ -80,7 +69,6 @@ type Config struct { CRD Resources Auth - Scalyr LogicalBackup WatchedNamespace string `name:"watched_namespace"` // special values: "*" means 'watch all namespaces', the empty string "" means 'watch a namespace where operator is deployed to'