2024-12-06 14:49:39 +01:00
|
|
|
# Local development with Kubernetes
|
|
|
|
|
|
|
|
|
|
We use tilt to provide a local development environment for Kubernetes.
|
|
|
|
|
Tilt is a tool that helps you develop applications for Kubernetes.
|
|
|
|
|
It watches your files for changes, rebuilds your containers, and restarts your pods.
|
|
|
|
|
It's like having a conversation with your cluster.
|
|
|
|
|
|
2025-02-04 18:37:32 +01:00
|
|
|
This is particularly useful when working on integrations or to test your helm charts.
|
|
|
|
|
Otherwise, you can use your good old docker configuration as described in README.md.
|
2024-12-06 14:49:39 +01:00
|
|
|
|
|
|
|
|
## Prerequisites
|
|
|
|
|
|
|
|
|
|
This guide assumes you have the following tools installed:
|
|
|
|
|
|
|
|
|
|
- [Docker](https://docs.docker.com/get-docker/)
|
|
|
|
|
- [Kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/)
|
|
|
|
|
- [Kind](https://kind.sigs.k8s.io/docs/user/quick-start/)
|
2025-02-04 18:37:32 +01:00
|
|
|
* [mkcert](https://github.com/FiloSottile/mkcert)
|
2024-12-06 14:49:39 +01:00
|
|
|
- [ctlptl](https://github.com/tilt-dev/ctlptl)
|
|
|
|
|
- [Tilt](https://docs.tilt.dev/install.html)
|
|
|
|
|
* [helm](https://helm.sh/docs/intro/install/)
|
|
|
|
|
* [helmfile](https://github.com/helmfile/helmfile)
|
|
|
|
|
* [secrets](https://github.com/jkroepke/helm-secrets/wiki/Installation)
|
|
|
|
|
|
2025-02-04 18:37:32 +01:00
|
|
|
[Install_prereq script](https://github.com/numerique-gouv/dk8s/blob/main/scripts/install-prereq.sh) (not tested).
|
2024-12-06 14:49:39 +01:00
|
|
|
|
|
|
|
|
### Helmfile in Docker
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
|
|
docker run --rm --net=host \
|
|
|
|
|
-v "${HOME}/.kube:/root/.kube" \
|
|
|
|
|
-v "${HOME}/.config/helm:/root/.config/helm" \
|
|
|
|
|
-v "${HOME}/.minikube:/${HOME}/.minikube" \
|
|
|
|
|
-v "${PWD}:/wd" \
|
|
|
|
|
-e KUBECONFIG=/root/.kube/config \
|
|
|
|
|
--workdir /wd ghcr.io/helmfile/helmfile:v0.150.0 helmfile "$@"
|
|
|
|
|
```
|
|
|
|
|
|
2025-02-04 18:37:32 +01:00
|
|
|
## Create the kubernetes cluster
|
2024-12-06 14:49:39 +01:00
|
|
|
|
|
|
|
|
Run the following command to create a kubernetes cluster using kind:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
make start-kind
|
2024-12-09 16:21:14 +01:00
|
|
|
|
2025-02-04 18:37:32 +01:00
|
|
|
# import your secrets from credentials manager
|
|
|
|
|
# ! don't forget "https" before your url
|
2024-12-09 16:21:14 +01:00
|
|
|
make install-external-secrets
|
|
|
|
|
```
|
|
|
|
|
|
2025-02-04 18:37:32 +01:00
|
|
|
That's it! You should now have a local development environment for Kubernetes.
|
2024-12-06 14:49:39 +01:00
|
|
|
|
2025-02-04 18:37:32 +01:00
|
|
|
## Start the application
|
2024-12-06 14:49:39 +01:00
|
|
|
|
|
|
|
|
```bash
|
2025-02-04 18:37:32 +01:00
|
|
|
# You can either start :
|
|
|
|
|
# ProConnect stack (but secrets must be set on your local cluster)
|
2024-12-06 14:49:39 +01:00
|
|
|
make tilt-up
|
2024-12-09 16:21:14 +01:00
|
|
|
|
2025-02-04 18:37:32 +01:00
|
|
|
# or standalone environment with keycloak
|
|
|
|
|
make start-tilt-keycloak
|
2024-12-06 14:49:39 +01:00
|
|
|
```
|
|
|
|
|
|
2025-02-04 18:37:32 +01:00
|
|
|
Access your application at https://desk.127.0.0.1.nip.io
|
2024-12-06 14:49:39 +01:00
|
|
|
|
|
|
|
|
## Management
|
|
|
|
|
|
|
|
|
|
To manage the cluster, you can use k9s.
|
|
|
|
|
|
|
|
|
|
## Next steps
|
|
|
|
|
|
|
|
|
|
- Add dimail to the local development environment
|
|
|
|
|
- Add a reset demo `cmd_button` to Tilt
|