Skip to content

Commit

Permalink
fix(cnpg-cluster): fix pooler monitoring (#40)
Browse files Browse the repository at this point in the history
Co-authored-by: Julien Bouquillon <julien.bouquillon@sg.social.gouv.fr>
  • Loading branch information
octomir and Julien Bouquillon authored Sep 5, 2023
1 parent 844d211 commit 5aa2805
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 47 deletions.
1 change: 1 addition & 0 deletions charts/cnpg-cluster/templates/pooler.cnpg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ metadata:
name: {{ include "cnpg-cluster.fullname" $ }}-{{ $name }}
labels:
{{- include "cnpg-cluster.labels" $ | nindent 4 }}
cnpg.io/poolerName: {{ include "cnpg-cluster.fullname" $ }}-{{ $name }}
spec:
cluster:
name: {{ include "cnpg-cluster.fullname" $ }}
Expand Down
120 changes: 74 additions & 46 deletions charts/cnpg-cluster/tests/__snapshot__/cnpg-cluster_test.yaml.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,52 @@ cluster with custom pgparams:
pg_hba: null
cluster with enabled backup and recovery:
1: |
backup:
barmanObjectStore:
destinationPath: s3://backups/
endpointURL: http://minio:9000
s3Credentials:
accessKeyId:
key: ACCESS_KEY_ID
name: minio
region:
key: DEFAULT_REGION
name: minio
secretAccessKey:
key: ACCESS_SECRET_KEY
name: minio
retentionPolicy: 30d
bootstrap:
recovery:
recoveryTarget:
targetTime: 2020-11-26 15:22:00.00000+00
source: recovery-cluster
externalClusters:
- barmanObjectStore:
destinationPath: s3://backups/
endpointURL: http://minio:9000
s3Credentials:
accessKeyId:
key: ACCESS_KEY_ID
name: minio
secretAccessKey:
key: ACCESS_SECRET_KEY
name: minio
serverName: my-cluster-to-restore
name: recovery-cluster
imageName: ghcr.io/cloudnative-pg/postgis:15
imagePullPolicy: IfNotPresent
instances: 1
maxSyncReplicas: 0
minSyncReplicas: 0
monitoring:
enablePodMonitor: false
postgresql:
parameters: null
pg_hba: null
storage:
size: 8Gi
2: |
concurrencyPolicy: Forbid
jobTemplate:
spec:
Expand Down Expand Up @@ -67,57 +113,39 @@ cluster with enabled backup and recovery:
runAsGroup: 1001
runAsUser: 1001
schedule: 4 5 * * 0
2: |
backup:
barmanObjectStore:
destinationPath: s3://backups/
endpointURL: http://minio:9000
s3Credentials:
accessKeyId:
key: ACCESS_KEY_ID
name: minio
region:
key: DEFAULT_REGION
name: minio
secretAccessKey:
key: ACCESS_SECRET_KEY
name: minio
retentionPolicy: 30d
bootstrap:
recovery:
recoveryTarget:
targetTime: 2020-11-26 15:22:00.00000+00
source: recovery-cluster
externalClusters:
- barmanObjectStore:
destinationPath: s3://backups/
endpointURL: http://minio:9000
s3Credentials:
accessKeyId:
key: ACCESS_KEY_ID
name: minio
secretAccessKey:
key: ACCESS_SECRET_KEY
name: minio
serverName: my-cluster-to-restore
name: recovery-cluster
imageName: ghcr.io/cloudnative-pg/postgis:15
imagePullPolicy: IfNotPresent
instances: 1
maxSyncReplicas: 0
minSyncReplicas: 0
monitoring:
enablePodMonitor: false
postgresql:
parameters: null
pg_hba: null
storage:
size: 8Gi
3: |
backupOwnerReference: self
cluster:
name: RELEASE-NAME-cnpg-cluster
schedule: 1 2 3 * * 0
cluster with monitoring:
1: |
apiVersion: postgresql.cnpg.io/v1
kind: Pooler
metadata:
labels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: cnpg-cluster
app.kubernetes.io/version: "15"
cnpg.io/poolerName: RELEASE-NAME-cnpg-cluster-rw
helm.sh/chart: cnpg-cluster-1.11.5
name: RELEASE-NAME-cnpg-cluster-rw
spec:
cluster:
name: RELEASE-NAME-cnpg-cluster
instances: 3
2: |
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: RELEASE-NAME-cnpg-cluster-rw
spec:
podMetricsEndpoints:
- port: metrics
selector:
matchLabels:
cnpg.io/poolerName: RELEASE-NAME-cnpg-cluster-rw
cluster with pg_basebackup:
1: |
- connectionParameters:
Expand Down
16 changes: 15 additions & 1 deletion charts/cnpg-cluster/tests/cnpg-cluster_test.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
suite: test cnpg-cluster
templates:
- cluster.cnpg.yaml
- pooler.cnpg.yaml
- backup-cron.yaml
- scheduledbackup.cnpg.yaml
tests:
Expand Down Expand Up @@ -71,7 +72,14 @@ tests:
- ./values/recovery.yaml
- ./values/backup.yaml
asserts:
- matchSnapshot:
- template: cluster.cnpg.yaml
matchSnapshot:
path: spec
- template: backup-cron.yaml
matchSnapshot:
path: spec
- template: scheduledbackup.cnpg.yaml
matchSnapshot:
path: spec
- template: backup-cron.yaml
hasDocuments:
Expand Down Expand Up @@ -113,3 +121,9 @@ tests:
- template: cluster.cnpg.yaml
matchSnapshot:
path: spec.bootstrap
- it: cluster with monitoring
values:
- ./values/monitor.yaml
asserts:
- template: pooler.cnpg.yaml
matchSnapshot: {}
6 changes: 6 additions & 0 deletions charts/cnpg-cluster/tests/values/monitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
monitoring:
enablePodMonitor: true

poolers:
rw:
instances: 3

0 comments on commit 5aa2805

Please sign in to comment.