Skip to content

Commit eb8e8b1

Browse files
Anmol1696claude
andcommitted
document k8s local development with Skaffold in DEVELOPMENT.md
Add section covering both plain k8s and Knative dev workflows, hot reload behavior, port map, and commands reference. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b1a0c04 commit eb8e8b1

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

DEVELOPMENT.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,72 @@ Local Node processes (functions):
179179

180180
Infrastructure runs in Docker. Functions run as local Node processes from `generated/` — no Docker rebuild needed when function code changes. Edit `functions/*/handler.ts`, rebuild (`pnpm build`), restart `make dev-fn`.
181181

182+
## K8s Local Development (Skaffold)
183+
184+
Run the entire stack in Kubernetes with hot-reload for handler code changes. Two modes are available:
185+
186+
### Prerequisites
187+
188+
- Docker Desktop with Kubernetes enabled (`kubectl get nodes` should work)
189+
- [Skaffold](https://skaffold.dev/docs/install/) CLI installed
190+
- For Knative mode: `cd k8s && make operators-knative-only`
191+
192+
### Option A: Plain k8s (no Knative)
193+
194+
Uses plain Deployments + Services. No operators needed beyond stock k8s.
195+
196+
```bash
197+
make skaffold-dev
198+
```
199+
200+
This runs `skaffold dev -p local-simple` which:
201+
1. Builds the `constructive-functions` Docker image from `Dockerfile.dev`
202+
2. Deploys postgres, constructive-server, db-setup, job-service, and functions to k8s
203+
3. Sets up port-forwarding automatically
204+
4. Watches `functions/**/*.ts` — edits are synced into running containers
205+
5. `tsx --watch` inside each function container detects changes and restarts
206+
207+
### Option B: Knative
208+
209+
Uses Knative Serving for functions (production parity). Requires Knative + Kourier.
210+
211+
```bash
212+
# One-time setup
213+
cd k8s && make operators-knative-only && cd ..
214+
215+
# Start dev loop
216+
make skaffold-dev-knative
217+
```
218+
219+
### Hot Reload
220+
221+
Handler code changes are hot-reloaded without rebuilding the Docker image:
222+
223+
1. Edit `functions/<name>/handler.ts`
224+
2. Skaffold detects the change and syncs the file into the running container
225+
3. `tsx --watch` picks up the change and restarts the process (~2-5 seconds)
226+
227+
Changes to runtime packages (`packages/fn-runtime`, `packages/fn-app`) or `package.json` trigger a full image rebuild (Skaffold handles this automatically).
228+
229+
### Port Map (Skaffold)
230+
231+
| Service | Local Port |
232+
|---------|------------|
233+
| simple-email | 8081 |
234+
| send-email-link | 8082 |
235+
| Job Service | 8080 |
236+
| PostgreSQL | 5432 |
237+
| Constructive Server | 3002 (Knative profile only) |
238+
239+
### Skaffold Commands Reference
240+
241+
| Command | Description |
242+
|---------|-------------|
243+
| `make skaffold-dev` | Start plain k8s dev loop |
244+
| `make skaffold-dev-knative` | Start Knative dev loop |
245+
| `skaffold build -p local-simple` | Build image only (no deploy) |
246+
| `skaffold delete -p local-simple` | Delete deployed resources |
247+
182248
## Troubleshooting
183249

184250
**db-setup fails or graphql-server won't start**

0 commit comments

Comments
 (0)