Skip to content

Latest commit

 

History

History
69 lines (44 loc) · 2.79 KB

Develop.md

File metadata and controls

69 lines (44 loc) · 2.79 KB

This file provides some hints and examples how to develop PREvant.

Backend Development

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.

Kubernetes Backend

For developing against a local Kubernetes cluster you can use k3d.

  1. Create a cluster:

    k3d cluster create dash -p "80:80@loadbalancer" -p "443:443@loadbalancer"
  2. 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
  3. 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
  4. 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

Frontend Development

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.

Static HTML

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.

Dev Server

  1. Start the backend as described in Backend Development.
  2. Change into the directory /frontend
  3. Build and run the frontend in the development mode
    npm ci
    npm run serve
  4. Open the URL http://localhost:9001 in your browser