Add K3D instructions

This commit is contained in:
Arnaud Delcasse 2024-11-18 12:06:38 +01:00
parent f97c8812fa
commit 76f49f7d1e
1 changed files with 22 additions and 12 deletions

View File

@ -2,11 +2,13 @@
Local dev environment for the COOPGO Technical Platform, using [Tilt](https://tilt.dev) and a local Kubernetes cluster (such as [Rancher Desktop](https://rancherdesktop.io/), K3D, ...) Local dev environment for the COOPGO Technical Platform, using [Tilt](https://tilt.dev) and a local Kubernetes cluster (such as [Rancher Desktop](https://rancherdesktop.io/), K3D, ...)
Tested with Rancher Desktop. Tested with Rancher Desktop and K3D.
## Quickstart ## Quickstart
1. Install Rancher Dektop or K3D or any other local Kubernetes. Make your Kubernetes context point to this cluster ### Install local cluster
Install Rancher Dektop or K3D or any other local Kubernetes. Make your Kubernetes context point to this cluster
Later, we will be using port 80 to access the cluster Ingress controller. On Linux, you must probably allow this. Later, we will be using port 80 to access the cluster Ingress controller. On Linux, you must probably allow this.
@ -16,11 +18,11 @@ sudo sysctl -w net.ipv4.ip_unprivileged_port_start=80
To preserve this change across reboots as a custom kernel parameter setting, add the same command inside your /etc/sysctl.conf file (or a dedicated /etc/sysctl.d/xxxxx.conf). To preserve this change across reboots as a custom kernel parameter setting, add the same command inside your /etc/sysctl.conf file (or a dedicated /etc/sysctl.d/xxxxx.conf).
### Rancher Desktop #### Rancher Desktop
See installation instructions here : https://docs.rancherdesktop.io/getting-started/installation See installation instructions here : https://docs.rancherdesktop.io/getting-started/installation
### K3D #### K3D
Install K3D : Install K3D :
@ -43,9 +45,13 @@ Create cluster :
k3d cluster create devcluster -p "80:80@loadbalancer" --registry-create devregistry:5000 --registry-config /tmp/k3d-registry.yaml k3d cluster create devcluster -p "80:80@loadbalancer" --registry-create devregistry:5000 --registry-config /tmp/k3d-registry.yaml
``` ```
2. [Install Tilt](https://docs.tilt.dev/install.html) ### Install Tilt
3. Create a .env file and configure environment [Follow instructions on Tilt documentation](https://docs.tilt.dev/install.html)
### Set the environment
Create a .env file and configure environment
For example, to set the source code directories (see default values in Tiltfile) : For example, to set the source code directories (see default values in Tiltfile) :
@ -71,7 +77,9 @@ MOBILITY_ACCOUNTS_IMAGE=my.own.registry/coopgo-platform/mobility-accounts
... ...
``` ```
If you're using K3D, remove the registry part. It should look something like this : #### K3D specific setup
If you're using K3D, remove the registry part in the images (we'll use K3D local registry instead). It should look something like this :
``` ```
PARCOURSMOB_IMAGE=coopgo-apps/parcoursmob PARCOURSMOB_IMAGE=coopgo-apps/parcoursmob
@ -79,19 +87,21 @@ MOBILITY_ACCOUNTS_IMAGE=coopgo-platform/mobility-accounts
... ...
``` ```
If using K3D again, set the K8S config to the dedicated overlay in k8s_config : Then, set the K8S config to the dedicated overlay in k8s_config :
``` ```
K8S_CONFIG="k8s_config/k3d" K8S_CONFIG="k8s_config/k3d"
``` ```
4. Add `tilt-dev.svc.cluster.local parcoursmob.tilt-dev.svc.cluster.local mobility-accounts.tilt-dev.svc.cluster.local` to resolve `127.0.0.1` in your hosts config (`/etc/hosts` on Linux) ### Set local hosts config
5. Run `tilt up` Add `tilt-dev.svc.cluster.local parcoursmob.tilt-dev.svc.cluster.local mobility-accounts.tilt-dev.svc.cluster.local` to resolve `127.0.0.1` in your hosts config (`/etc/hosts` on Linux)
6. After some time (you can see the services loading -or failing, if there is an error- through Tilt UI), PARCOURSMOB should be available on http://parcoursmob.tilt-dev.svc.cluster.local ### Run the dev environment and start developing
To have this work, make sure port 80 is unprivileged if you're using Linux. This is described in Rancher Desktop documentation. If you're using something else to run Kubernetes, make sure you have the right port forwarding and an Ingress controller on your cluster to target port 80 on localhost. Run `tilt up`
After some time (you can see the services loading -or failing, if there is an error- through Tilt UI), PARCOURSMOB should be available on http://parcoursmob.tilt-dev.svc.cluster.local
Once you can acess PARCOURSMOB UI, you can connect with the initially created user : Once you can acess PARCOURSMOB UI, you can connect with the initially created user :