Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
53 changes: 53 additions & 0 deletions k8s/postgres-cluster-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: high-command-postgres
namespace: high-command
spec:
instances: 3
postgresql:
parameters:
max_connections: "200"
shared_buffers: "256MB"
effective_cache_size: "1GB"
maintenance_work_mem: "64MB"
checkpoint_completion_target: "0.9"
wal_buffers: "16MB"
default_statistics_target: "100"
random_page_cost: "1.1"
effective_io_concurrency: "200"
work_mem: "4MB"
min_wal_size: "1GB"
max_wal_size: "4GB"
max_worker_processes: "4"
max_parallel_workers_per_gather: "2"
max_parallel_workers: "4"
max_parallel_maintenance_workers: "2"

bootstrap:
initdb:
database: highcommand
owner: highcommand
secret:
name: high-command-postgres-credentials

storage:
size: 10Gi
storageClass: truenas-nfs

resources:
requests:
memory: "512Mi"
cpu: "500m"
limits:
memory: "1Gi"
cpu: "1000m"
---
# Prerequisites:
# 1. CloudNativePG operator must be installed in the cluster
# 2. Create the postgres-credentials secret first (see postgres-credentials-example.yaml)
# 3. Ensure the storage class 'truenas-nfs' exists (or change to your storage class)
#
# Deployment:
# kubectl apply -f k8s/postgres-credentials-example.yaml
# kubectl apply -f k8s/postgres-cluster-example.yaml
19 changes: 19 additions & 0 deletions k8s/postgres-credentials-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Secret
metadata:
name: high-command-postgres-credentials
namespace: high-command
type: Opaque
stringData:
username: highcommand
password: CHANGE_ME_TO_SECURE_PASSWORD
---
# Example: Create this secret using kubectl:
#
# kubectl create secret generic high-command-postgres-credentials \
# --from-literal=username=highcommand \
# --from-literal=password='your-secure-password-here' \
# -n high-command
#
# Or generate a secure password:
# openssl rand -base64 32
16 changes: 16 additions & 0 deletions k8s/postgres-database-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: postgresql.cnpg.io/v1
kind: Database
metadata:
name: highcommand
namespace: high-command
spec:
cluster:
name: high-command-postgres
owner: highcommand
---
# This Database resource is optional if the database was created during cluster bootstrap.
# The cluster bootstrap (in postgres-cluster-example.yaml) already creates the 'highcommand' database.
# This resource is useful for managing additional databases or if you need to recreate the database.
#
# Deployment:
# kubectl apply -f k8s/postgres-database-example.yaml
29 changes: 29 additions & 0 deletions k8s/postgres-pooler-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: postgresql.cnpg.io/v1
kind: Pooler
metadata:
name: high-command-postgres-pooler
namespace: high-command
spec:
cluster:
name: high-command-postgres
instances: 2
type: rw
pgbouncer:
parameters:
pool_mode: transaction
max_client_conn: "1000"
default_pool_size: "25"
reserve_pool_size: "5"
---
# PgBouncer connection pooler for PostgreSQL cluster.
# Provides connection pooling to reduce connection overhead.
#
# Prerequisites:
# 1. PostgreSQL cluster must be running (see postgres-cluster-example.yaml)
#
# Deployment:
# kubectl apply -f k8s/postgres-pooler-example.yaml
#
# Connection strings:
# Read-write: postgresql://user:pass@high-command-postgres-rw.high-command.svc.cluster.local:5432/highcommand
# Pooler: postgresql://user:pass@high-command-postgres-pooler-rw.high-command.svc.cluster.local:5432/highcommand