Skip to content

Commit

Permalink
chore: add more options to example Postgres clusters (#10)
Browse files Browse the repository at this point in the history
Closes #9

Signed-off-by: Gabriele Bartolini <[email protected]>
  • Loading branch information
gbartolini committed Oct 20, 2024
1 parent 4818263 commit b175a27
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 24 deletions.
48 changes: 38 additions & 10 deletions examples/eu/cluster-dc-eu.yaml → examples/eu/pg-eu.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: cluster-dc-eu
name: pg-eu
spec:
instances: 3

storage:
size: 1Gi

# See https://cloudnative-pg.io/documentation/current/storage/#volume-for-wal
walStorage:
size: 1Gi

# See https://cloudnative-pg.io/documentation/current/scheduling/#isolating-postgresql-workloads
affinity:
nodeSelector:
node-role.kubernetes.io/postgres: ""
Expand All @@ -19,6 +24,27 @@ spec:
topologyKey: kubernetes.io/hostname
podAntiAffinityType: required

# See https://cloudnative-pg.io/documentation/current/bootstrap/#bootstrap-an-empty-cluster-initdb
bootstrap:
initdb:
dataChecksums: true

postgresql:
# See https://cloudnative-pg.io/documentation/current/postgresql_conf/#the-postgresql-section
parameters:
# Some very basic Postgres settings
max_connections: '100'
log_checkpoints: 'on'
log_lock_waits: 'on'
pg_stat_statements.max: '10000'
pg_stat_statements.track: 'all'
hot_standby_feedback: 'on'
# Note: `remote_apply` slows down write operations
synchronous_commit: 'remote_apply'
# Container images work fine with sysv shared memory
shared_memory_type: 'sysv'
dynamic_shared_memory_type: 'sysv'

backup:
barmanObjectStore:
destinationPath: s3://backups/
Expand All @@ -33,15 +59,16 @@ spec:
wal:
compression: gzip

# See https://cloudnative-pg.io/documentation/current/replica_cluster/#distributed-topology
replica:
self: cluster-dc-eu
primary: cluster-dc-eu
source: cluster-dc-us
self: pg-eu
primary: pg-eu
source: pg-us

externalClusters:
- name: cluster-dc-eu
- name: pg-eu
barmanObjectStore:
serverName: cluster-dc-eu
serverName: pg-eu
destinationPath: s3://backups/
endpointURL: http://minio-eu:9000
s3Credentials:
Expand All @@ -53,9 +80,9 @@ spec:
key: ACCESS_SECRET_KEY
wal:
compression: gzip
- name: cluster-dc-us
- name: pg-us
barmanObjectStore:
serverName: cluster-dc-us
serverName: pg-us
destinationPath: s3://backups/
endpointURL: http://minio-us:9000
s3Credentials:
Expand All @@ -68,13 +95,14 @@ spec:
wal:
compression: gzip
---
# See https://cloudnative-pg.io/documentation/current/backup/#scheduled-backups
apiVersion: postgresql.cnpg.io/v1
kind: ScheduledBackup
metadata:
name: cluster-dc-eu-backup
name: pg-eu-backup
spec:
schedule: '0 0 0 * * *'
backupOwnerReference: self
cluster:
name: cluster-dc-eu
name: pg-eu
immediate: true
52 changes: 38 additions & 14 deletions examples/us/cluster-dc-us.yaml → examples/us/pg-us.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: cluster-dc-us
name: pg-us
spec:
instances: 3

storage:
size: 1Gi

# See https://cloudnative-pg.io/documentation/current/storage/#volume-for-wal
walStorage:
size: 1Gi

# See https://cloudnative-pg.io/documentation/current/scheduling/#isolating-postgresql-workloads
affinity:
nodeSelector:
node-role.kubernetes.io/postgres: ""
Expand All @@ -19,6 +24,27 @@ spec:
topologyKey: kubernetes.io/hostname
podAntiAffinityType: required

# See https://cloudnative-pg.io/documentation/current/recovery/
bootstrap:
recovery:
source: pg-eu

postgresql:
# See https://cloudnative-pg.io/documentation/current/postgresql_conf/#the-postgresql-section
parameters:
# Some very basic Postgres settings
max_connections: '100'
log_checkpoints: 'on'
log_lock_waits: 'on'
pg_stat_statements.max: '10000'
pg_stat_statements.track: 'all'
hot_standby_feedback: 'on'
# Note: `remote_apply` slows down write operations
synchronous_commit: 'remote_apply'
# Container images work fine with sysv shared memory
shared_memory_type: 'sysv'
dynamic_shared_memory_type: 'sysv'

backup:
barmanObjectStore:
destinationPath: s3://backups/
Expand All @@ -33,19 +59,16 @@ spec:
wal:
compression: gzip

bootstrap:
recovery:
source: cluster-dc-eu

# See https://cloudnative-pg.io/documentation/current/replica_cluster/#distributed-topology
replica:
self: cluster-dc-us
primary: cluster-dc-eu
source: cluster-dc-eu
self: pg-us
primary: pg-eu
source: pg-eu

externalClusters:
- name: cluster-dc-eu
- name: pg-eu
barmanObjectStore:
serverName: cluster-dc-eu
serverName: pg-eu
destinationPath: s3://backups/
endpointURL: http://minio-eu:9000
s3Credentials:
Expand All @@ -57,9 +80,9 @@ spec:
key: ACCESS_SECRET_KEY
wal:
compression: gzip
- name: cluster-dc-us
- name: pg-us
barmanObjectStore:
serverName: cluster-dc-us
serverName: pg-us
destinationPath: s3://backups/
endpointURL: http://minio-us:9000
s3Credentials:
Expand All @@ -72,13 +95,14 @@ spec:
wal:
compression: gzip
---
# See https://cloudnative-pg.io/documentation/current/backup/#scheduled-backups
apiVersion: postgresql.cnpg.io/v1
kind: ScheduledBackup
metadata:
name: cluster-dc-us-backup
name: pg-us-backup
spec:
schedule: '0 0 0 * * *'
backupOwnerReference: self
cluster:
name: cluster-dc-us
name: pg-us
immediate: true

0 comments on commit b175a27

Please sign in to comment.