INIT(postgresql): databases setup

- with pg and pg-dev
This commit is contained in:
2025-12-17 15:09:48 +09:00
commit 27838e5bad
14 changed files with 493 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
# Prometheus Postgres Exporter Helm Values for postgresql-read-0
# Chart: https://github.com/prometheus-community/helm-charts/tree/main/charts/prometheus-postgres-exporter
fullnameOverride: postgres-exporter-read-0
config:
datasource:
host: postgresql-read-0.postgresql-read-hl.postgresql.svc.cluster.local
port: "5432"
user: bluemayne
passwordSecret:
name: postgresql-password
key: password
database: postgres
sslmode: disable
serviceMonitor:
enabled: true
namespace: monitoring
additionalLabels:
release: prometheus
instance: postgres-exporter-read-0
resources:
requests:
memory: 64Mi
cpu: 50m

View File

@@ -0,0 +1,27 @@
# Prometheus Postgres Exporter Helm Values for postgresql-read-1
# Chart: https://github.com/prometheus-community/helm-charts/tree/main/charts/prometheus-postgres-exporter
fullnameOverride: postgres-exporter-read-1
config:
datasource:
host: postgresql-read-1.postgresql-read-hl.postgresql.svc.cluster.local
port: "5432"
user: bluemayne
passwordSecret:
name: postgresql-password
key: password
database: postgres
sslmode: disable
serviceMonitor:
enabled: true
namespace: monitoring
additionalLabels:
release: prometheus
instance: postgres-exporter-read-1
resources:
requests:
memory: 64Mi
cpu: 50m

View File

@@ -0,0 +1,27 @@
# Prometheus Postgres Exporter Helm Values
# Chart: https://github.com/prometheus-community/helm-charts/tree/main/charts/prometheus-postgres-exporter
# Note: This exporter monitors postgresql-primary
fullnameOverride: postgres-exporter
config:
datasource:
host: postgresql-primary.postgresql.svc.cluster.local
port: "5432"
user: bluemayne
passwordSecret:
name: postgresql-password
key: password
database: postgres
sslmode: disable
serviceMonitor:
enabled: true
namespace: monitoring
additionalLabels:
release: prometheus
resources:
requests:
memory: 64Mi
cpu: 50m

View File

@@ -0,0 +1,95 @@
# PostgreSQL (Production) Helm Values
# Chart: https://github.com/bitnami/charts/tree/main/bitnami/postgresql
# Architecture: Primary + 2 Read Replicas with streaming replication
fullnameOverride: postgresql
# Use latest tag (ARM64 compatible)
image:
tag: latest
architecture: replication
auth:
existingSecret: postgresql-password
secretKeys:
adminPasswordKey: postgres-password
userPasswordKey: password
replicationPasswordKey: replication-password
username: bluemayne
database: postgres
primary:
persistence:
enabled: true
size: 20Gi
storageClass: local-path
# PostgreSQL configuration
extendedConfiguration: |
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 = 1310kB
min_wal_size = 1GB
max_wal_size = 4GB
resources:
requests:
memory: "512Mi"
cpu: "30m" # Reduced to 30% of original (100m -> 30m)
readReplicas:
replicaCount: 2
persistence:
enabled: true
size: 20Gi
storageClass: local-path
# PostgreSQL configuration (must match primary for replication)
extendedConfiguration: |
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 = 1310kB
min_wal_size = 1GB
max_wal_size = 4GB
# Force read replicas to different nodes for better availability
# Avoid scheduling on the same node as primary or other read replicas
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchLabels:
app.kubernetes.io/component: read
app.kubernetes.io/instance: postgresql
app.kubernetes.io/name: postgresql
topologyKey: kubernetes.io/hostname
- labelSelector:
matchLabels:
app.kubernetes.io/component: primary
app.kubernetes.io/instance: postgresql
app.kubernetes.io/name: postgresql
topologyKey: kubernetes.io/hostname
resources:
requests:
memory: "512Mi"
cpu: "30m" # Reduced to 30% of original (100m -> 30m)
# Metrics for Prometheus (disabled due to ARM64 compatibility)
metrics:
enabled: false