Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postgreslet: Backup exporter sidecar #106

Merged
merged 36 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
230040f
Bump version
eberlep Sep 16, 2024
6089cb4
Update postgreslet image
eberlep Sep 16, 2024
7b6d51c
Add webhook svc template
eberlep Sep 16, 2024
7e195c5
Add webhook registration template
eberlep Sep 16, 2024
a3d94cd
Add (initial) webhook server certificate
eberlep Sep 16, 2024
8d150ba
Mount webhook server certificate into postgreslet pod
eberlep Sep 16, 2024
168a481
Switch back to self-signed cert
eberlep Sep 16, 2024
6aa2452
Change to dnsNames
eberlep Sep 16, 2024
cdccb10
auto-inject caBundle
eberlep Sep 16, 2024
066dbba
Make webhook configurable
eberlep Sep 16, 2024
c89b2f9
Use tagged release
eberlep Sep 16, 2024
086b757
Make all webhook resources configurable
eberlep Sep 16, 2024
d671bad
Separate ifs
eberlep Sep 16, 2024
7f3f0e0
Trry moving things around
eberlep Sep 16, 2024
1c8108e
Move things around
eberlep Sep 16, 2024
f5a1d51
Switch from mutating sts to pods
eberlep Oct 17, 2024
18440cd
Don't call webhhook on pod UPDATEs
eberlep Oct 24, 2024
e0d6c16
Bump postgreslet version
eberlep Oct 24, 2024
6d40c35
Merge remote-tracking branch 'origin' into postgreslet-mutating-webhook
eberlep Nov 8, 2024
0b16275
Bump chart version
eberlep Nov 8, 2024
28b26ea
Add backup-exporter sidecar
eberlep Nov 8, 2024
587fe6c
Revert "Move things around"
eberlep Nov 8, 2024
6561969
Don't render (or reference0 webhook certificate when webhook is disabled
eberlep Nov 8, 2024
800acc4
Merge branch 'postgreslet-mutating-webhook' into backup-exporter-sidecar
eberlep Nov 8, 2024
87112c2
Make sidecar configurable
eberlep Nov 11, 2024
b7ad237
Add PGDATABASE variable to backup-sidecar
eberlep Nov 11, 2024
b5a1df7
Merge remote-tracking branch 'origin' into backup-exporter-sidecar
eberlep Nov 12, 2024
82995e4
Make mountPath respect feature flag too
eberlep Nov 12, 2024
c5be822
Pass along walg-exporter port configuration to the postgreslet
eberlep Nov 15, 2024
f338941
Make use of wal-g-exporter configurable
eberlep Nov 15, 2024
65536f1
This is the end.
eberlep Dec 6, 2024
393a260
Merge remote-tracking branch 'origin' into backup-exporter-sidecar
eberlep Jan 14, 2025
4452044
add pg_sync_standby_nominal_actual and pg_replication_blocked_transac…
TLINDEN Jan 16, 2025
ecdf306
Update spilo image
eberlep Jan 16, 2025
791cbbe
Update postgreslet image
eberlep Jan 20, 2025
333e90d
Use specific version for backup-exporter
eberlep Jan 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/postgreslet/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.15.0
version: 0.16.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
41 changes: 41 additions & 0 deletions charts/postgreslet/templates/configmap-sidecars.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ apiVersion: v1
data:
postgres-exporter-service-port: {{ .Values.sidecars.exporter.servicePort | quote }}
postgres-exporter-service-target-port: {{ .Values.sidecars.exporter.containerPort | quote }}
{{- if .Values.sidecars.walGExporter.enabled }}
wal-g-exporter-service-port: {{ .Values.sidecars.walGExporter.servicePort | quote }}
wal-g-exporter-service-target-port: {{ .Values.sidecars.walGExporter.containerPort | quote }}
{{- end }}
{{- if .Values.sidecars.exporter.enableStatementsQuery }}
queries.yaml: {{ printf "%s\n%s" .Values.sidecars.exporter.queries .Values.sidecars.exporter.queriesStatements | b64enc }}
{{- else }}
Expand Down Expand Up @@ -69,6 +73,34 @@ data:
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault
{{- if .Values.sidecars.walGExporter.enabled }}
- name: "backup-exporter"
image: "{{ .Values.sidecars.walGExporter.imageRepository }}:{{ .Values.sidecars.walGExporter.imageTag }}"
env:
- name: PGHOST
value: 127.0.0.1
- name: PGPORT
value: "5432"
- name: PGPASSWORD
valueFrom:
secretKeyRef:
key: password
- name: PGUSER
value: monitoring
- name: PGDATABASE
value: postgres
ports:
- name: backup-exporter
containerPort: {{ .Values.sidecars.walGExporter.containerPort }}
protocol: TCP
resources:
requests:
cpu: {{ .Values.sidecars.walGExporter.resources.requests.cpu }}
memory: {{ .Values.sidecars.walGExporter.resources.requests.memory }}
limits:
cpu: {{ .Values.sidecars.walGExporter.resources.limits.cpu }}
memory: {{ .Values.sidecars.walGExporter.resources.limits.memory }}
{{- end }}
additional-volumes: |
- name: empty
mountPath: /opt/empty
Expand Down Expand Up @@ -96,6 +128,15 @@ data:
items:
- key: fluent-bit.conf
path: fluent-bit.conf
{{- if .Values.sidecars.walGExporter.enabled }}
- mountPath: /run/etc
name: walg
targetContainers:
- postgres
- backup-exporter
volumeSource:
emptyDir: {}
{{- end }}
kind: ConfigMap
metadata:
name: {{ include "postgreslet.fullname" . }}-postgres-sidecars
Expand Down
1 change: 1 addition & 0 deletions charts/postgreslet/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ data:
ENABLE_STANDBY_LEADER_SELECTOR: {{ .Values.postgreslet.enableStandbyLeaderSelector | quote }}
ENABLE_SUPERUSER_FOR_DBO: {{ .Values.postgreslet.enableSuperuserforDBO | quote }}
ENABLE_WALG_ENCRYPTION: {{ .Values.postgreslet.enableWalGEncryption | quote }}
ENABLE_WAL_G_EXPORTER: {{ .Values.sidecars.walGExporter.enabled | quote }}
ETCD_BACKUP_SECRET_NAME: {{ .Values.postgreslet.etcdBackupSecretName | quote }}
{{- if .Values.postgreslet.etcdBackupSidecarImage }}
ETCD_BACKUP_SIDECAR_IMAGE: {{ .Values.postgreslet.etcdBackupSidecarImage | quote }}
Expand Down
66 changes: 64 additions & 2 deletions charts/postgreslet/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ replicaCount: 1
image:
repository: r.metal-stack.io/postgreslet
pullPolicy: IfNotPresent
tag: "v0.17.1"
tag: "v0.18.0"

imagePullSecrets: []
nameOverride: ""
Expand Down Expand Up @@ -91,7 +91,7 @@ postgreslet:
# postgresImageRepository
postgresImageRepository: "docker.io/cybertecpostgresql/spilo"
# postgresImageTag
postgresImageTag: "3.2-p3_de-sync-standby-cluster_0.4_2024-07-02"
postgresImageTag: "3.3-p2_de-sync-standby-cluster_0.4_2024-11-27"
# etcdHost The connection string for Patroni defined as host:port. Not required when native Kubernetes support is used. The default is empty (use Kubernetes-native DCS).
etcdHost: ""
# enableCrdValidation toggles if the operator will create or update CRDs with OpenAPI v3 schema validation
Expand Down Expand Up @@ -433,6 +433,55 @@ sidecars:
- size:
usage: "GAUGE"
description: "Disk space used by the database"

pg_sync_standby_nominal_actual:
query: "WITH config AS (
SELECT
COALESCE(ARRAY_LENGTH(STRING_TO_ARRAY(setting, ','), 1), 0)
AS nominal_sync_standbys
FROM
pg_settings
WHERE
name = 'synchronous_standby_names'
),
current AS (
SELECT
COUNT(*) AS actual_sync_standbys
FROM
pg_stat_replication
WHERE
sync_state = 'sync'
)
SELECT
config.nominal_sync_standbys,
current.actual_sync_standbys,
CASE
WHEN current.actual_sync_standbys >= config.nominal_sync_standbys THEN 1
ELSE 0
END AS status
FROM
config, current"
metrics:
- nominal_sync_standbys:
usage: "GAUGE"
description: "The number of nominal (configured) sync standbys"
- actual_sync_standbys:
usage: "GAUGE"
description: "The number of actual subscribed standbys"
- status:
usage: "GAUGE"
description: "Result of nominal-actual-comparision: 1=OK, 0=Fail (sync standbys are missing)"

pg_replication_blocked_transactions:
query: "SELECT COUNT(*) AS blocked_transactions
FROM pg_stat_activity
WHERE state = 'active'
AND wait_event='SyncRep'"
metrics:
- blocked_transactions:
usage: "COUNTER"
description: "Number of blocked transactions waiting for a defect sync standby"

queriesStatements: |+
pg_stat_statements:
# user, datname, query, calls, total_exec_time, rows.
Expand Down Expand Up @@ -491,3 +540,16 @@ sidecars:
$$;
GRANT pg_monitor to monitoring;
GRANT pg_read_all_stats TO monitoring;
walGExporter:
enabled: true
imageRepository: "ghcr.io/thedatabaseme/wal-g-exporter"
imageTag: "0.3.1"
containerPort: 9351
servicePort: 9351
resources:
requests:
cpu: "100m"
memory: "100M"
limits:
cpu: "500m"
memory: "256M"
Loading