Deploy Payload CMS 3.0 + Postgres on Kubernetes: Production-Ready Template

Deploying a modern headless CMS with a relational database on a cluster requires robust networking, persistent data management, and reliable lifecycle probes. This template provisions a high-availability configuration designed to deploy Payload CMS on Kubernetes. Running Payload Kubernetes manifests coordinates containerized Next.js standalone execution paths alongside an isolated PostgreSQL stateful storage engine.
| Component | Type | Port | Role |
|---|---|---|---|
| payload-cms | Deployment | 3000 | Runs the custom, standalone Next.js and Payload CMS application server image |
| payload-cms | Service | 3000 | Exposes the Payload CMS server internally to the cluster |
| postgres | StatefulSet | 5432 | Manages the PostgreSQL database engine and persistent disks |
| postgres-headless | Service | 5432 | Provides stable network identities for individual PostgreSQL pods |
| payload-production-config | ConfigMap | None | Stores non-sensitive system configurations and environment keys |
| payload-production-secrets | Secret | None | Secures sensitive tokens and database connection strings |
Traffic flows into the cluster hitting the payload-cms Service, which balances stateless traffic across application pods. Payload CMS connects over the internal network to the postgres StatefulSet using a headless service interface for predictable hostname resolution. Database tables seed automatically via an integrated initContainer that blocks the application server runtime from starting up until PostgreSQL fully accepts connections on port 5432.
payload-production-config ConfigMap to verify regional configuration values.payload-production-secrets manifest with your base64-encoded database credentials and encryption keys.kubectl port-forward svc/payload-cms 3000:3000 -n production.http://localhost:3000/admin in your web browser to confirm the Payload CMS login view loads successfully.kubectl logs deployment/payload-cms -n production to verify successful database migrations.kubectl get pods -n production to check that the startup, readiness, and liveness HTTP probes return status code 200.This template configures a secure, multi-stage Payload CMS deployment using a custom container image tied to a local PostgreSQL data layer with automated network probes.