Local Development
Go Backend
The Go Backend acts as:
- Backend store and API for the Policy Report pushes
- File server for the NuxtJS single page application (the actual UI)
- HTTP proxy for the Policy Reporter REST API
- HTTP proxy for the Kyverno plugin REST API (if enabled)
Requirements
- Go >= v1.19
Getting started
Fork and/or checkout Policy Reporter UI on GitHub
The Go Backend is located in the ./server
directory
Install dependencies
cd servergo get ./...
Running Policy Reporter UI
go run main.go -no-ui -dev -port=8082
Argument Reference
Argument | Description | Default |
---|---|---|
-config | path to the Policy Reporter UI config file | config.yaml |
-dev | adds the Access-Control-Allow-Origin HTTP header to all APIs to avoid CORS errors | false |
-no-ui | disables the SPA handler to start the backend without the UI, only for development purposes | false |
-policy-reporter | Host URL to Policy Reporter, used to proxy API requests to and from the UI | |
-kyverno-plugin | Host URL to Policy Reporter Kyverno plugin, used to proxy API requests to and from the UI | |
-port | used port for the HTTP server | 8080 |
Compile and run Policy Reporter UI
make build./build/policyreporter-ui -no-ui -dev -port=8082
NuxtJS Frontend
The actual frontend is a single page application based on NuxtJS and TypeScript.
Requirements
- NodeJS >= v16
- Local running Policy Reporter UI backend
- Accessible Policy Reporter REST API
- Accessible Kyverno plugin REST API (optional)
Preparation
Access Policy Reporter via port forwarding:
kubectl port-forward service/policy-reporter 8080:8080 -n policy-reporter
Access Policy Reporter Kyverno plugin via port forwarding:
kubectl port-forward service/policy-reporter-kyverno-plugin 8083:8080 -n policy-reporter
Start the Policy Reporter UI server in development mode without the UI. The server has to be started in the server
directory of the Policy Reporter UI project.
go run main.go -no-ui -dev -port=8082 -policy-reporter http://localhost:8080 -kyverno-plugin http://localhost:8083
Install Dependencies
Dependencies are managed with NPM.
npm install
Running Policy Reporter UI
Create a .env file to configure the Policy Reporter UI backend URL. With this setup you can just copy the prepared .env.example
.
cp .env.example .env
Start the NuxtJS development server
npm run dev
Open http://localhost:3000.
Check the output of the npm run dev
command if this port is not working.