1# Kubernetes tutorial
2
3The complete stack from the [five-part Kubernetes tutorial](https://alchemy.run/kubernetes/tutorial/part-1): a local kind cluster with podinfo in its own namespace, an Effect smoke-test Job, the same program as a CronJob, and metrics-server from its Helm chart.
4
5## Requirements
6
7- [Docker](https://docs.docker.com/get-started/get-docker/), running
8- [kind](https://kind.sigs.k8s.io/docs/user/quick-start/#installation)
9- [helm](https://helm.sh/docs/intro/install/)
10- [kubectl](https://kubernetes.io/docs/tasks/tools/), to inspect the cluster
11
12## Run
13
14From the repository root, install dependencies with `pnpm install`. Then:
15
16```sh
17cd examples/kubernetes-tutorial
18bun run deploy
19```
20
21The first deploy creates a kind cluster named `alchemy` (context `kind-alchemy`) with an image registry on `localhost:5001`, then builds and pushes the smoke test and health check.
22
23```sh
24kubectl --context kind-alchemy -n my-app get deployments,jobs,cronjobs
25kubectl --context kind-alchemy -n my-app logs job/<smokeTest>
26bun run destroy
27```
28
29`--stage prod` targets a kubeconfig context named `prod` and pushes to `ghcr.io/you`. Edit `src/infra.ts` for your cluster and registry first, as described in [Part 5](https://alchemy.run/kubernetes/tutorial/part-5).
30
31## Test
32
33```sh
34timeout 400 bun test
35```
36
37The test deploys the stack to a fresh local cluster, waits for the smoke-test Job to complete, checks the Deployment, CronJob, and metrics-server, and destroys everything afterward. Set `NO_DESTROY=1` to keep the cluster for inspection.