NestJS on Kubernetes
Structured TypeScript APIs with a health check, a dev pod and a production image.
larakube nestjs:newnestjs:new starts a NestJS API with the Nest CLI, adds the health endpoint Kubernetes needs, and generates a dev pod for your machine plus a production image and manifests for the cloud. NestJS is the first framework on LaraKube CLI's server-app engine, so the other non-PHP frameworks follow the path it proves.
Every piece is built, but nobody has run the full walkthrough yet: scaffold, run locally, build the image, deploy through CI. Try it, but don't promise it to a client until this badge turns green.
🚀 Create a project
larakube nestjs:new api
LaraKube CLI runs the official @nestjs/cli inside a node:24-alpine container, under Docker or Podman, so you don't need Node on your machine. The project uses npm and strict TypeScript, without a git repository of its own. Then it asks:
| Choice | Options | With --fast |
|---|---|---|
| Database | PostgreSQL (recommended), MySQL, MariaDB | PostgreSQL |
| Cache | Redis (recommended), Memcached | Redis |
| Object storage | None, MinIO (recommended), SeaweedFS, Garage | MinIO |
| Search | None, Meilisearch (meilisearch-js), Typesense (typesense-js) | None |
🧱 What LaraKube CLI adds
| File | What it does |
|---|---|
src/health.controller.ts | A /healthz endpoint returning {"status":"ok"}, registered in AppModule |
Dockerfile.nestjs | Installs dependencies, runs nest build, prunes to production dependencies, and starts node dist/main.js on port 3000 |
.dockerignore | Keeps your machine's node_modules and dist out of the image |
.infrastructure/ | A dev pod for local work, and a Deployment, Service and Ingress for each cloud environment |
Using Prisma? Once the project has prisma/schema.prisma, the next time LaraKube CLI regenerates its infrastructure the image runs prisma generate, and prisma migrate deploy runs in an init container before new pods take traffic.
🗄️ Databases and services
Your answers to the wizard are saved in .larakube.json, but LaraKube CLI doesn't provision a database, cache or storage for NestJS yet. There are no database pods, and nestjs:new doesn't join the Plex Commons. Point the app at services you run yourself for now; it will join the Commons once that's wired and verified.
💻 Run it locally
cd api
larakube up
The dev pod runs npm run start:dev on port 3000 and reloads as you edit. https://api.<your local domain>/healthz should return {"status":"ok"}.
☁️ Deploy
Create the cloud environment and its CI workflow:
larakube env production
Runtime values never go in the repository or the workflow. Put them in .env.production, then push them to the cluster:
larakube dotenv:push production
Commit and push. The workflow builds Dockerfile.nestjs, pushes the image, and rolls out the app. It stops with a clear error if you haven't run dotenv:push yet, rather than starting pods with no configuration.
➡️ Next
- Cluster Tools and your apps — how your app sits beside the ready-made tools on the same cluster.
- All frameworks — the other stacks LaraKube CLI scaffolds.