Skip to content

Commit

Permalink
update cnpg config
Browse files Browse the repository at this point in the history
  • Loading branch information
carpenike committed Nov 25, 2024
1 parent c97c926 commit f21885e
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
apiVersion: helm.toolkit.fluxcd.io/v2beta2
# yaml-language-server: $schema=https://kubernetes-schemas.pages.dev/helm.toolkit.fluxcd.io/helmrelease_v2.json
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: cloudnative-pg
spec:
interval: 15m
interval: 30m
chart:
spec:
chart: cloudnative-pg
version: 0.21.5
version: 0.22.1
sourceRef:
kind: HelmRepository
name: cloudnative-pg
Expand All @@ -21,8 +22,6 @@ spec:
remediation:
strategy: rollback
retries: 3
uninstall:
keepHistory: false
values:
crds:
create: true
Expand Down
31 changes: 14 additions & 17 deletions kubernetes/cluster-0/apps/db/cloudnative-pg/cluster/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,23 @@ spec:
storageClass: local-hostpath
superuserSecret:
name: cloudnative-pg-secret
bootstrap:
recovery:
source: &previous-cluster postgres-v8
enableSuperuserAccess: true
postgresql:
parameters:
max_connections: "300"
shared_buffers: 512MB
pg_stat_statements.max: "10000"
pg_stat_statements.track: all
resources:
requests:
cpu: 500m
limits:
memory: 4Gi
monitoring:
enablePodMonitor: true
backup:
retentionPolicy: 30d
barmanObjectStore:
barmanObjectStore: &barmanObjectStore
wal:
compression: bzip2
maxParallel: 8
Expand All @@ -40,19 +43,13 @@ spec:
secretAccessKey:
name: cloudnative-pg-secret
key: aws-secret-access-key
bootstrap:
recovery:
source: &previousCluster postgres-v8

# Note: externalClusters is needed when recovering from an existing cnpg cluster
externalClusters:
- name: *previous-cluster
- name: *previousCluster
barmanObjectStore:
wal:
compression: bzip2
maxParallel: 8
destinationPath: s3://postgresql/
endpointURL: https://minio-s3.holthome.net
s3Credentials:
accessKeyId:
name: cloudnative-pg-secret
key: aws-access-key-id
secretAccessKey:
name: cloudnative-pg-secret
key: aws-secret-access-key
<<: *barmanObjectStore
serverName: *previousCluster
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
# yaml-language-server: $schema=https://kubernetes-schemas.devbu.io/monitoring.coreos.com/prometheusrule_v1.json
# yaml-language-server: $schema=https://kubernetes-schemas.pages.dev/monitoring.coreos.com/prometheusrule_v1.json
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
Expand Down Expand Up @@ -31,10 +31,10 @@ spec:
severity: warning
- alert: PGDatabase
annotations:
description: Over 150,000,000 transactions from frozen xid on pod {{ $labels.pod }}
description: Over 300,000,000 transactions from frozen xid on pod {{ $labels.pod }}
summary: Number of transactions from the frozen XID to the current one
expr: |-
cnpg_pg_database_xid_age > 150000000
cnpg_pg_database_xid_age > 300000000
for: 1m
labels:
severity: warning
Expand All @@ -50,9 +50,9 @@ spec:
- alert: LastFailedArchiveTime
annotations:
description: Archiving failed for {{ $labels.pod }}
summary: Checks the last time archiving failed. Will be -1 when it has not failed.
summary: Checks the last time archiving failed. Will be < 0 when it has not failed.
expr: |-
delta(cnpg_pg_stat_archiver_last_failed_time[5m]) > 0
(cnpg_pg_stat_archiver_last_failed_time - cnpg_pg_stat_archiver_last_archived_time) > 1
for: 1m
labels:
severity: warning
Expand All @@ -65,3 +65,12 @@ spec:
for: 1m
labels:
severity: warning
- alert: ReplicaFailingReplication
annotations:
description: Replica {{ $labels.pod }} is failing to replicate
summary: Checks if the replica is failing to replicate
expr: |-
cnpg_pg_replication_in_recovery > cnpg_pg_replication_is_wal_receiver_up
for: 1m
labels:
severity: warning
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ apiVersion: v1
kind: Service
metadata:
name: postgres-lb
namespace: db
annotations:
external-dns.alpha.kubernetes.io/hostname: postgres.holthome.net
io.cilium/lb-ipam-ips: 10.45.20.15
Expand All @@ -16,4 +15,4 @@ spec:
targetPort: 5432
selector:
cnpg.io/cluster: postgres
role: primary
cnpg.io/instanceRole: primary
21 changes: 14 additions & 7 deletions kubernetes/cluster-0/apps/db/cloudnative-pg/ks.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,44 @@
---
# yaml-language-server: $schema=https://kubernetes-schemas.pages.dev/kustomize.toolkit.fluxcd.io/kustomization_v1.json
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: cloudnative-pg
name: &app cloudnative-pg
namespace: flux-system
spec:
targetNamespace: db
commonMetadata:
labels:
app.kubernetes.io/name: *app
path: ./kubernetes/cluster-0/apps/db/cloudnative-pg/app
prune: true
sourceRef:
kind: GitRepository
name: k8s-gitops-kubernetes
wait: true
interval: 30m
retryInterval: 1m
timeout: 5m
dependsOn:
- name: external-secrets-stores
---
# yaml-language-server: $schema=https://kubernetes-schemas.pages.dev/kustomize.toolkit.fluxcd.io/kustomization_v1.json
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: cloudnative-pg-cluster
name: &app cloudnative-pg-cluster
namespace: flux-system
spec:
targetNamespace: db
dependsOn:
- name: cloudnative-pg
- name: external-secrets-stores
commonMetadata:
labels:
app.kubernetes.io/name: *app
path: ./kubernetes/cluster-0/apps/db/cloudnative-pg/cluster
prune: true
sourceRef:
kind: GitRepository
name: k8s-gitops-kubernetes
wait: true
interval: 30m
retryInterval: 1m
timeout: 5m
dependsOn:
- name: cloudnative-pg

0 comments on commit f21885e

Please sign in to comment.