You can work on your app in three ways:
- Using your local Node.js installation
- In a container running in Docker
- In a container running in Kubernetes
If you use homebrew, just run
brew bundle
to make use of our Brewfile
Optional:
You need to start your local cluster before you can use the yarn k8s:
commands.
There are many clusters to choose from.
You should test various options until you find one that is suitable for your environment and your level of k8s understanding. Personally, I like the cluster that comes with Docker Desktop because built images are instantly available in the cluster which makes the feedback loop shorter. Second on my list is k3d which also has a desktop app.
You'll probably also want to install Lens.
-
Install dependencies with
nvm install && nvm use && yarn
-
Start your app:
-
Local:
yarn dev
-
Docker:
yarn docker:dev
-
Kubernetes:
yarn k8s:dev
If not using Docker desktop, expect the first start to be much slower as the base image layer is downloaded from the remote registry, pushed to a local registry, and finally downloaded to your cluster from the local registry.
-
-
Watch the logs:
- Local/Docker: in your terminal
- Kubernetes: in your terminal by pressing
s
or pressspace
to watch them in the Tilt UI
-
View your app on http://localhost:3000
- Change something in your source code
- Watch your logs and see how quickly the server is restarted
- Refresh your browser and you should see the change in your app
Your app comes with several plugins for observability, refer to the observability section for more details.
- Start a local Jaeger instance:
yarn jaeger:init
- Open the Jaeger UI: http://localhost:16686
- Make a request to your app
- Note the
trace_id
in the logs and search for it in the Jaeger UI
Depending on your chosen local cluster solution, it may or may not be able to access the above created Jaeger instance. If not, follow these steps to run a Jaeger instance in k8s:
- In
manifests/k8s/deployment.yaml
, set the value ofOTEL_EXPORTER_JAEGER_ENDPOINT
environment variable tohttp://jaeger:14268/api/traces
- When starting your app, make use of the infra_tiltfile flag.
(eg.
yarn k8s:dev --infra_tiltfile ./hack/example-infra/k8s/Tiltfile
) - This configures access to Jaeger UI on http://localhost:16687 so the port doesn't clash with the other Jaeger instance running for local/docker development.
For production-like testing on your local machine:
- Docker:
yarn docker:prod
- Kubernetes:
yarn k8s:prod
The distroless debug image is the same image as the prod image but with shell access.
- Docker:
yarn docker:debug
- Kubernetes:
yarn k8s:debug
- Add a breakpoint to a line in your code
- Go to the Run and Debug tab
- Choose the debugger configuration for your running app from the dropdown:
- Local: Attach to Node.js
- Docker/k8s (dev): Attach to Node.js
- Docker/k8s (debug): Attach to Node.js
- Click on Start debugging (F5)
- Refresh your app in your browser
- You can see the app stopping at the breakpoint
- Continue debugging in VS Code
- Edit
name
andconfig.image
inpackage.json
- Update manifests
- Update documentation
- Edit
engines.node
inpackage.json
- Edit
.nvmrc