-
Notifications
You must be signed in to change notification settings - Fork 5
Home
We will update it as soon as we release it!
This guide walks you through setting up the local development environment from scratch using k3d, tilt, and CloudNativePG.
Before continuing, make sure you have the following installed:
Tilt supports multiple clusters and they have different levels of difficulty. See this page for more details.
Create a k3d cluster named igniter with a local container registry.
k3d cluster create igniter --registry-create igniter-registry
Verify it's working:
kubectl get nodes
The output is something like this:
NAME STATUS ROLES AGE VERSION
k3d-igniter-server-0 Ready control-plane,master 16s v1.31.5+k3s1
The operator version is vendored in the repo under:
deploy/postgres/operator
Install it with:
kubectl apply --server-side -f deploy/postgres/operator
You can confirm it is running:
kubectl get pods -n cnpg-system
You should see a pod like cloudnative-pg-controller-manager-xxxx in a Running state.
NAME READY STATUS RESTARTS AGE
cnpg-controller-manager-5d478566fb-z29x5 1/1 Running 0 33s
Run:
tilt up
Tilt will:
- Generate a TLS certificate and a
postgres-tlsKubernetes secret (if not already present) - Generate a random PostgreSQL password and write it to
postgres-secrets.yml - Create a Kubernetes secret named
postgres-secrets - Create a
postgres-middleman-connectionsecret with a full DATABASE_URL pointing at your cluster - Apply the Postgres dev cluster and wait for readiness
- Build the
middlemanDocker image locally via the Dockerfile atdeploy/middleman/middleman.dockerfile - Apply Kubernetes manifests under
deploy/middleman/dev - Start port-forwards:
- Postgres: localhost:5432 β cluster
- Middleman: localhost:3000 β container
Once services are up, you'll see logs and status updates in Tilt's dashboard.
Here are some key folders you'll be working with:
- apps/middleman β Your Next.js app (Next 15)
- deploy/postgres β Postgres dev cluster resources
- deploy/postgres/operator β CloudNativePG manifests
- deploy/middleman β Middleman Kubernetes manifests
To tear everything down, run:
tilt down
This will also remove generated secrets and certs from disk:
- deploy/postgres/dev/postgres-secrets.yml
- deploy/postgres/dev/postgres-tls.yml
- deploy/postgres/dev/certs/server.crt
- deploy/postgres/dev/certs/server.key
- The
postgres-middleman-connectionsecret is updated every time a new password is generated. - If you want to inspect logs or port-forwards outside of Tilt, run:
kubectl get pods
kubectl logs <pod-name>
kubectl port-forward <pod> 3000:3000
Happy hacking!