Post

PostgreSQL

PostgreSQL

PostgreSQL

Shared PostgreSQL 16 instance used by other homelab services (Media Indexer, Postgres MCP, and connections registered in pgAdmin). Runs in the default namespace of the k3s cluster.

Deployment

ItemValue
Imagepostgres:16
Namespacedefault
Replicas1 (Recreate strategy)
ServiceLoadBalancer, port 5432 (MetalLB-assigned external IP 192.168.1.33)
Storagepostgres-data PVC, 5Gi, longhorn storage class, mounted at /var/lib/postgresql/data
Data directoryPGDATA=/var/lib/postgresql/data/pgdata (subdirectory of the PVC mount, avoiding issues with lost+found in the volume root)
CredentialsPOSTGRES_USER / POSTGRES_PASSWORD / POSTGRES_DB loaded in full via envFrom.secretRef from the postgres-secret Secret
Auto-reloadreloader.stakater.com/auto: "true"

Storage

Uses the longhorn storage class rather than local-path: the single replica has no node affinity pinning it to a specific node, so a Longhorn-backed volume (which replicates across nodes and binds Immediate) lets the pod reschedule elsewhere without losing data if its current node goes down.

Access

The LoadBalancer Service exposes Postgres directly on the LAN at 192.168.1.33:5432 — there’s no ingress/TLS layer in front of it, since the Postgres wire protocol isn’t HTTP. Consumers on the cluster (Postgres MCP, Media Indexer) instead reach it via the in-cluster DNS name postgres.default.svc.cluster.local:5432.

This post is licensed under CC BY 4.0 by the author.