This file provides some hints and examples how to develop PREvant.
You can build PREvant's backend API with cargo
in the sub directory /api
. For example, cargo run
build and starts the backend so that it will be available at http://localhost:8000
.
When you than interact with the REST API to deploy service, it is worthwhile to have a look into the Traefik dashboard to double check if PREvant exposes the services as expected.
If you want to use PREvant's frontend during development, head over to the Frontend Development section.
Without any CLI options, PREvant will use the Docker API. If you want to develop with against Kubernetes, have a look into the Kubernetes section.
For developing against a local Kubernetes cluster you can use k3d.
-
Create a cluster:
k3d cluster create dash -p "80:80@loadbalancer" -p "443:443@loadbalancer"
-
Start PREvant with Kubernetes (it will infer the cluster configuration by searching for kube-config file or in-cluster environment variables)
cargo run -- --runtime-type Kubernetes
-
Deploy some containers and observe the result here:
curl -X POST -d '[{"serviceName": "whoami", "image": "quay.io/truecharts/whoami:1.8.1"}]' \ -H "Content-type: application/json" \ http://localhost:8000/api/apps/master
-
Check Traefik's dashboard by exposing the port (see command below and detail here) and visit
http://localhost:9000/dashboard
.kubectl -n kube-system port-forward $(kubectl -n kube-system get pods --selector "app.kubernetes.io/name=traefik" --output name) 9000:9000
You can build PREvant's frontend with npm
in the sub directory /frontend
. You can build the static HTML files or serve the HTML files via the dev server.
To create the static HTML files that can be served by PREvant's backend (see above, you need to run following commands and start the backend.
npm ci
npm run build
PREvant will be available at http://localhost:8000
.
- Start the backend as described in Backend Development.
- Change into the directory
/frontend
- Build and run the frontend in the development mode
npm ci npm run serve
- Open the URL
http://localhost:9001
in your browser