I've been doing full-stack development and server administration for many years, but Kubernetes is relatively new to me. I built a small three-node cluster for learning and already have development and production pipelines, linting, and security scans running. Now I want to deploy one of my React projects with a separate backend and database.
Locally, I use .env files to switch between local and development services. At work, an internal tool manages environment variables, but for my own cluster I'd like to use standard Kubernetes practices. Should database host and port settings go in a ConfigMap, with credentials stored in a Secret? Is that the normal approach for small projects?
I also assume the database should run separately from the backend pod. Should I start with a database Deployment or StatefulSet backed by a PersistentVolumeClaim, use something like CloudNativePG, or choose another approach? If the project eventually becomes public, I may move it to a cloud provider with managed database services. I'd appreciate advice on whether my overall plan is sound and what I should learn first.
4 Answers
The split itself sounds right: frontend, backend, and database should be separate components. Also make sure the backend is stateless before adding multiple replicas. It should be safe to kill and replace any backend pod without losing sessions, temporary files, locks, or in-progress work. Put shared sessions or other durable state in a suitable external service instead of relying on one pod’s memory or filesystem.
For a real public deployment, I’d strongly lean toward a managed database unless operating PostgreSQL is part of the project’s purpose. Kubernetes is excellent for stateless application workloads, but databases require careful backup testing, storage planning, upgrades, monitoring, and recovery procedures. For your personal cluster, running PostgreSQL with a StatefulSet is a useful exercise; for production, a managed database or a well-supported operator is usually the less risky choice.
ConfigMaps for ordinary settings and Secrets for credentials are the standard starting point. Inject them into the backend as environment variables or mounted files. For a small learning project, that’s perfectly reasonable; use Helm or another deployment tool to keep the configuration repeatable. As systems grow, you might consider Vault, OpenBao, a cloud secrets manager, or encrypted Git-based approaches such as SOPS or Sealed Secrets. Just don’t commit unencrypted credentials to version control.
For databases, managed services are usually preferable in production because backups, upgrades, replication, and recovery are handled for you. Running one in Kubernetes is possible, but it adds operational work. If you do run it yourself, use persistent storage and a database operator rather than treating the database like a disposable stateless container.
You can learn the fundamentals without starting with a database operator. Run PostgreSQL separately from the backend, using a StatefulSet and a PersistentVolumeClaim, then expose it internally through a Kubernetes Service. The backend can connect to a stable service name such as the database Service name rather than an individual pod address.
That will teach you about storage, ports, Services, and database initialization. Once the basics make sense, try CloudNativePG or move the database to a managed service such as a hosted PostgreSQL offering. A PVC alone gives you storage, not automatic backups, failover, upgrades, or recovery, so don’t mistake it for a complete production database solution.

Related Questions
Can't Load PhpMyadmin On After Server Update
Redirect www to non-www in Apache Conf
How To Check If Your SSL Cert Is SHA 1
Windows TrackPad Gestures