Local Development
Requirements
- Go >= v1.19
- (optional) Kubernetes Cluster with wgpolicyk8s.io CRDs installed
Getting started
Fork and/or checkout Policy Reporter on GitHub
Install dependencies
go get ./...
Unit Tests
Run unit tests locally with
make test
or
go test -v ./... -timeout=10s
Running Policy Reporter
To run Policy Reporter locally, you must connect it to a Kubernetes cluster. This is required because it connects to the Kubernetes API to watch for PolicyReports and ClusterPolicyReports. The configuration can be done via CLI arguments, config.yaml, or a mix of both.
go run main.go run -k ~/.kube/config
Argument Reference
Argument | Short | Description | Default |
---|---|---|---|
--kubeconfig | -k | path to the kubeconfig file, used to connect to the Kubernetes API | |
--config | -c | path to the Policy Reporter config file | config.yaml |
--dbfile | -d | path to the SQLite database file | sqlite-database.db |
--metrics-enabled | -m | enables the Metrics API endpoints | false |
--rest-enabled | -r | enables the REST API endpoints | false |
--port | -p | used port for the HTTP server | 8080 |
Compile and run Policy Reporter
make build./build/policyreporter run -k ~/.kube/config