- server.js uses pg (pinned 8.23.1), reads DATABASE_URL, creates the leads table on start, fails fast if Postgres is unreachable - tests run against a real Postgres in a throwaway schema - CI runs the test image against a throwaway Postgres on DinD - k8s: Postgres 18 StatefulSet (Longhorn, 2Gi), init container wait, password secret, network policy app-to-postgres; app no longer needs a volume or Recreate - README: DBeaver via port-forward, CSV export via docs/export-leads.sql Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfmHGGiYUjNcvJoyzdf
85 lines
2.0 KiB
YAML
85 lines
2.0 KiB
YAML
apiVersion: v1
|
|
kind: PersistentVolumeClaim
|
|
metadata:
|
|
name: ins-landing-page-postgres
|
|
namespace: ins-landing-page
|
|
spec:
|
|
storageClassName: longhorn
|
|
# ReadWriteOnce, not ReadWriteMany: Longhorn serves RWX over NFS, which a database should not
|
|
# write through. One replica mounts it.
|
|
accessModes:
|
|
- ReadWriteOnce
|
|
resources:
|
|
requests:
|
|
storage: 2Gi
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: postgres
|
|
namespace: ins-landing-page
|
|
spec:
|
|
clusterIP: None
|
|
selector:
|
|
app: postgres
|
|
ports:
|
|
- name: postgres
|
|
port: 5432
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: StatefulSet
|
|
metadata:
|
|
name: postgres
|
|
namespace: ins-landing-page
|
|
spec:
|
|
serviceName: postgres
|
|
replicas: 1
|
|
selector:
|
|
matchLabels:
|
|
app: postgres
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: postgres
|
|
spec:
|
|
terminationGracePeriodSeconds: 60
|
|
containers:
|
|
- name: postgres
|
|
image: postgres:18
|
|
env:
|
|
- name: POSTGRES_USER
|
|
value: ins
|
|
- name: POSTGRES_DB
|
|
value: ins
|
|
- name: POSTGRES_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: ins-landing-page-db
|
|
key: POSTGRES_PASSWORD
|
|
ports:
|
|
- name: postgres
|
|
containerPort: 5432
|
|
readinessProbe:
|
|
exec:
|
|
command: ["pg_isready", "-U", "ins", "-d", "ins"]
|
|
periodSeconds: 5
|
|
livenessProbe:
|
|
exec:
|
|
command: ["pg_isready", "-U", "ins", "-d", "ins"]
|
|
periodSeconds: 20
|
|
failureThreshold: 6
|
|
resources:
|
|
requests:
|
|
cpu: 100m
|
|
memory: 128Mi
|
|
limits:
|
|
memory: 1Gi
|
|
volumeMounts:
|
|
# postgres:18 keeps its data under /var/lib/postgresql/<major>/docker.
|
|
- name: data
|
|
mountPath: /var/lib/postgresql
|
|
volumes:
|
|
- name: data
|
|
persistentVolumeClaim:
|
|
claimName: ins-landing-page-postgres
|