Local Development

Requirements

  • Go >= v1.19
  • (optional) Kubernetes Cluster with Kyverno installed

Getting started

Fork and/or checkout Policy Reporter Kyverno plugin on GitHub

Install dependencies

go get ./...

Unit Tests

Run unit tests locally with

make test

or

go test -v ./... -timeout=10s

Running Kyverno Plugin

To run the Kyverno plugin locally, you must connect it to a Kubernetes cluster. This is required because it connects to the Kubernetes API to watch for Kyverno Policies and ClusterPolicies. 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

ArgumentShortDescriptionDefault
--kubeconfig-kpath to the kubeconfig file,
used to connect to the Kubernetes API
--config-cpath to the Policy Reporter config fileconfig.yaml
--metrics-enabled-menables the Metrics API endpointsfalse
--rest-enabled-renables the REST API endpointsfalse
--port-pused port for the HTTP server8080

Compile and run Policy Reporter

make build./build/kyverno-plugin run -k ~/.kube/config