From c7442812a8129d314b9d89235509b70ded6d846e Mon Sep 17 00:00:00 2001 From: Sheogorath <sheogorath@shivering-isles.com> Date: Sun, 24 Apr 2022 22:52:44 +0200 Subject: [PATCH] feat(postgres-system): Move sidecar and podMonitor to system namespace This patch moves the setup of the sidecar containers and the podMonitor to the `postgres-system` namespace, providing monitoring for all namespaces, not just for some. Reduces the copy-paste work and should allow nice insights into all postgres clusters. --- apps/base/matrix/database.yaml | 30 ------------------------- infrastructure/postgres/podmonitor.yaml | 21 +++++++++++++++++ infrastructure/postgres/release.yaml | 25 +++++++++++++++++++++ renovate.json | 13 ++++++++++- 4 files changed, 58 insertions(+), 31 deletions(-) create mode 100644 infrastructure/postgres/podmonitor.yaml diff --git a/apps/base/matrix/database.yaml b/apps/base/matrix/database.yaml index 1fe7d4810..e6b87d010 100644 --- a/apps/base/matrix/database.yaml +++ b/apps/base/matrix/database.yaml @@ -28,36 +28,6 @@ spec: limits: cpu: "1" memory: 3072Mi - sidecars: - - name: "exporter" - image: "quay.io/prometheuscommunity/postgres-exporter" - ports: - - name: exporter - containerPort: 9187 - protocol: TCP - resources: - limits: - cpu: 500m - memory: 256M - requests: - cpu: 100m - memory: 200M - env: - - name: "DATA_SOURCE_URI" - value: "$(POD_NAME)/postgres?sslmode=require" - - name: "DATA_SOURCE_USER" - value: "$(POSTGRES_USER)" - - name: "DATA_SOURCE_PASS" - value: "$(POSTGRES_PASSWORD)" - - name: "PG_EXPORTER_AUTO_DISCOVER_DATABASES" - value: "true" - - name: PG_EXPORTER_CONSTANT_LABELS - value: 'release=$(CLUSTER_NAME),namespace=$(POD_NAMESPACE)' - - name: CLUSTER_NAME - valueFrom: - fieldRef: - apiVersion: v1 - fieldPath: metadata.labels['cluster-name'] --- apiVersion: monitoring.coreos.com/v1 kind: PodMonitor diff --git a/infrastructure/postgres/podmonitor.yaml b/infrastructure/postgres/podmonitor.yaml new file mode 100644 index 000000000..57409ffca --- /dev/null +++ b/infrastructure/postgres/podmonitor.yaml @@ -0,0 +1,21 @@ +--- +apiVersion: monitoring.coreos.com/v1 +kind: PodMonitor +metadata: + name: postgresql + namespace: postgres-system +spec: + selector: + matchLabels: + application: spilo + podMetricsEndpoints: + - port: exporter + interval: 15s + scrapeTimeout: 10s + - targetPort: 8008 + interval: 15s + scrapeTimeout: 10s + podTargetLabels: + - spilo-role + - cluster-name + - team diff --git a/infrastructure/postgres/release.yaml b/infrastructure/postgres/release.yaml index 0a51bc792..7e20fd914 100644 --- a/infrastructure/postgres/release.yaml +++ b/infrastructure/postgres/release.yaml @@ -21,5 +21,30 @@ spec: upgrade: crds: CreateReplace values: + configGeneral: + sidecars: + - name: "exporter" + # renovate: + image: "quay.io/prometheuscommunity/postgres-exporter:v0.10.1" + ports: + - name: exporter + containerPort: 9187 + protocol: TCP + resources: + limits: + cpu: 500m + memory: 256M + requests: + cpu: 100m + memory: 200M + env: + - name: "DATA_SOURCE_URI" + value: "$(POD_NAME)/postgres?sslmode=require" + - name: "DATA_SOURCE_USER" + value: "$(POSTGRES_USER)" + - name: "DATA_SOURCE_PASS" + value: "$(POSTGRES_PASSWORD)" + - name: "PG_EXPORTER_AUTO_DISCOVER_DATABASES" + value: "true" configKubernetes: enable_pod_antiaffinity: true diff --git a/renovate.json b/renovate.json index d1501c0d5..b2200f1d1 100644 --- a/renovate.json +++ b/renovate.json @@ -11,5 +11,16 @@ "semanticCommits": "enabled", "flux": { "fileMatch": ["\\.yaml$"] - } + }, + "regexManagers": [ + { + "fileMatch": ["*.yaml$"], + "matchStrings": [ + "# renovate:\\n\\s+image: \"?\'?(?<depName>[^:\\s]+?):(?<currentValue>[^\"]*?)\"?\'?\\s" + ], + "datasourceTemplate": "docker", + "versioningTemplate": "docker" + } + ], + } -- GitLab