2026-01-24 13:06:07 +01:00
|
|
|
apiVersion: v1
|
|
|
|
|
kind: Service
|
|
|
|
|
metadata:
|
|
|
|
|
name: postgres
|
|
|
|
|
namespace: phoenix
|
|
|
|
|
labels:
|
|
|
|
|
app: postgres
|
|
|
|
|
spec:
|
|
|
|
|
type: ClusterIP
|
|
|
|
|
ports:
|
|
|
|
|
- port: 5432
|
|
|
|
|
targetPort: 5432
|
|
|
|
|
name: postgres
|
|
|
|
|
selector:
|
|
|
|
|
app: postgres
|
|
|
|
|
clusterIP: None # Headless service for StatefulSet
|
|
|
|
|
---
|
|
|
|
|
apiVersion: apps/v1
|
|
|
|
|
kind: StatefulSet
|
|
|
|
|
metadata:
|
|
|
|
|
name: postgres
|
|
|
|
|
namespace: phoenix
|
|
|
|
|
labels:
|
|
|
|
|
app: postgres
|
|
|
|
|
spec:
|
|
|
|
|
serviceName: postgres
|
|
|
|
|
replicas: 1
|
|
|
|
|
selector:
|
|
|
|
|
matchLabels:
|
|
|
|
|
app: postgres
|
|
|
|
|
template:
|
|
|
|
|
metadata:
|
|
|
|
|
labels:
|
|
|
|
|
app: postgres
|
|
|
|
|
spec:
|
2026-02-02 20:47:09 +01:00
|
|
|
# Prevent scheduling on Raspberry Pi due to resource requirements (256Mi-1Gi memory, 250m-1000m CPU)
|
|
|
|
|
nodeSelector:
|
|
|
|
|
hardware: high-memory
|
2026-01-24 13:06:07 +01:00
|
|
|
containers:
|
|
|
|
|
- name: postgres
|
2026-01-24 14:39:26 +01:00
|
|
|
image: postgres:16
|
2026-01-24 13:06:07 +01:00
|
|
|
ports:
|
|
|
|
|
- containerPort: 5432
|
|
|
|
|
name: postgres
|
|
|
|
|
env:
|
|
|
|
|
- name: POSTGRES_USER
|
|
|
|
|
valueFrom:
|
|
|
|
|
secretKeyRef:
|
|
|
|
|
name: phoenix-secret
|
|
|
|
|
key: POSTGRES_USER
|
|
|
|
|
- name: POSTGRES_PASSWORD
|
|
|
|
|
valueFrom:
|
|
|
|
|
secretKeyRef:
|
|
|
|
|
name: phoenix-secret
|
|
|
|
|
key: POSTGRES_PASSWORD
|
|
|
|
|
- name: POSTGRES_DB
|
|
|
|
|
valueFrom:
|
|
|
|
|
secretKeyRef:
|
|
|
|
|
name: phoenix-secret
|
|
|
|
|
key: POSTGRES_DB
|
|
|
|
|
- name: PGDATA
|
|
|
|
|
value: /var/lib/postgresql/data/pgdata
|
|
|
|
|
# PostgreSQL optimization settings
|
|
|
|
|
- name: POSTGRES_INITDB_ARGS
|
|
|
|
|
value: "-E UTF8"
|
|
|
|
|
args:
|
|
|
|
|
- "postgres"
|
|
|
|
|
- "-c"
|
|
|
|
|
- "shared_preload_libraries=pg_stat_statements"
|
|
|
|
|
- "-c"
|
|
|
|
|
- "pg_stat_statements.track=all"
|
|
|
|
|
- "-c"
|
|
|
|
|
- "shared_buffers=256MB"
|
|
|
|
|
- "-c"
|
|
|
|
|
- "effective_cache_size=1GB"
|
|
|
|
|
- "-c"
|
|
|
|
|
- "maintenance_work_mem=128MB"
|
|
|
|
|
- "-c"
|
|
|
|
|
- "checkpoint_completion_target=0.9"
|
|
|
|
|
- "-c"
|
|
|
|
|
- "wal_buffers=16MB"
|
|
|
|
|
- "-c"
|
|
|
|
|
- "default_statistics_target=100"
|
|
|
|
|
- "-c"
|
|
|
|
|
- "random_page_cost=1.1"
|
|
|
|
|
- "-c"
|
|
|
|
|
- "effective_io_concurrency=200"
|
|
|
|
|
- "-c"
|
|
|
|
|
- "work_mem=8MB"
|
|
|
|
|
- "-c"
|
|
|
|
|
- "min_wal_size=1GB"
|
|
|
|
|
- "-c"
|
|
|
|
|
- "max_wal_size=4GB"
|
|
|
|
|
volumeMounts:
|
|
|
|
|
- name: postgres-data
|
|
|
|
|
mountPath: /var/lib/postgresql/data
|
|
|
|
|
resources:
|
|
|
|
|
requests:
|
|
|
|
|
memory: "256Mi"
|
|
|
|
|
cpu: "250m"
|
|
|
|
|
limits:
|
|
|
|
|
memory: "1Gi"
|
|
|
|
|
cpu: "1000m"
|
|
|
|
|
readinessProbe:
|
|
|
|
|
exec:
|
|
|
|
|
command:
|
|
|
|
|
- /bin/sh
|
|
|
|
|
- -c
|
|
|
|
|
- pg_isready -U postgres
|
|
|
|
|
initialDelaySeconds: 10
|
|
|
|
|
periodSeconds: 10
|
|
|
|
|
timeoutSeconds: 5
|
|
|
|
|
successThreshold: 1
|
|
|
|
|
failureThreshold: 3
|
|
|
|
|
livenessProbe:
|
|
|
|
|
exec:
|
|
|
|
|
command:
|
|
|
|
|
- /bin/sh
|
|
|
|
|
- -c
|
|
|
|
|
- pg_isready -U postgres
|
|
|
|
|
initialDelaySeconds: 30
|
|
|
|
|
periodSeconds: 30
|
|
|
|
|
timeoutSeconds: 5
|
|
|
|
|
successThreshold: 1
|
|
|
|
|
failureThreshold: 3
|
|
|
|
|
volumeClaimTemplates:
|
|
|
|
|
- metadata:
|
|
|
|
|
name: postgres-data
|
|
|
|
|
spec:
|
|
|
|
|
accessModes: ["ReadWriteOnce"]
|
|
|
|
|
resources:
|
|
|
|
|
requests:
|
|
|
|
|
storage: 8Gi
|