dev-environment/README.md

3.1 KiB

COOPGO Dev environment

Local dev environment for the COOPGO Technical Platform, using Tilt and a local Kubernetes cluster (such as Rancher Desktop, K3D, ...)

Tested with Rancher Desktop.

Quickstart

  1. Install Rancher Dektop or K3D or any other local Kubernetes. Make your Kubernetes context point to this cluster

  2. Install Tilt

  3. Create a .env file and configure environment

For example, to set the source code directories (see default values in Tiltfile) :

PARCOURSMOB_DIR="../../coopgo-apps/parcoursmob"
MOBILITY_ACCOUNTS_DIR="../../coopgo-platform/mobility-accounts"
AGENDA_DIR="../../coopgo-platform/agenda"
FLEETS_DIR="../../coopgo-platform/fleets"
GROUPS_MANAGEMENT_DIR="../../coopgo-platform/groups-management"

To avoid developing on another cluster than the one dedicated for dev, we whitelist the correct context. By default, the allowed context is 'rancher-desktop'. To change this, set ALLOWED_K8S_CONTEXT to the correct context name in .env :

ALLOWED_K8S_CONTEXT="k3d-devcluster"

You might also want to set the default container images used if/while your local source code folder doesn't exist.

PARCOURSMOB_IMAGE=my.own.registry/coopgo-platform/parcoursmob@v1.2
MOBILITY_ACCOUNTS_IMAGE=my.own.registry/coopgo-platform/mobility-accounts
...
  1. 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)

  2. Run tilt up

  3. 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

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.

Once you can acess PARCOURSMOB UI, you can connect with the initially created user :

Now, you're ready to code !

What it does

Set up PARCOURSMOB along with the following dependencies :

  • COOPGO microservices :
    • Mobility Accounts
    • Groups Management
    • Fleets
    • Agenda
    • Carpool service (coming soon)
  • Other software Dependencies :
    • MongoDB (Next step, deploy with PostgreSQL as both should be supported)
    • Etcd for caching values
    • Minio to store files
    • smtp4dev to test outgoing emails

Tilt handles livereloading Kubernetes pods when something changes in the code. You just have to checkout your code in the directory you've specified in .env (see quickstart), start developing on exsting microservices, and see the changes.

Acess useful internal components for debugging/tests

Access smtp4dev to check outgoing emails :

  1. Forward smtp4dev service locally : kubectl port-forward svc/smtp4dev 9090:80
  2. Access UI : http://localhost:9090/