Setup development environment
Kubewarden Network Enforcer uses Tilt for local development.
Prerequisites
-
On a supported Linux host to run a local kubernetes cluster.
-
Setup golang development environments.
-
A C compiler (
gccor equivalent).
Steps
-
Clone the repository:
git clone https://github.com/kubewarden/network-enforcer.git cd network-enforcer -
Copy Tilt settings:
cp tilt-settings.yaml.example tilt-settings.yaml -
Create a kind cluster with a provider and start Tilt.
E2E_PROVIDERisistio,calico, orcilium:make setup-dev-cluster E2E_PROVIDER=istioThis creates a kind cluster named
kind, installs the provider and cert-manager, then runstilt up. Tilt’s UI is typically http://localhost:10350. -
Check that the controller is up:
kubectl get pods -n network-enforcer kubectl get workloadnetworkpolicyproposals.networkenforcer.kubewarden.io -A -
When you are done, stop Tilt (
Ctrl-C) and delete the cluster:make delete-dev-cluster
Tests
make test
That runs envtest unit tests (everything except ./test/e2e).
E2E tests need a dedicated kind cluster (istio, calico, or cilium), not a shared or production cluster:
make test-e2e E2E_PROVIDER=istio
Helm chart unit tests live under charts/network-enforcer/tests/. Install the helm-unittest plugin if you want to run them:
make helm-unit-test
Optional
golangci-lint
You may want to install a pre-commit hook for golangci-lint, so you can fix linter issues locally.
-
Install golangci-lint, e.g.
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.13.2(the version pinned in the Makefile).make lint-fixalso downloads that binary intobin/. -
Install pre-commit hooks. You can also use tools like husky or pre-commit.
cat << EOF > .git/hooks/pre-commit
#!/bin/sh
golangci-lint run
EOF
chmod +x .git/hooks/pre-commit
If you are using pre-commit, install the hooks defined in .pre-commit-config.yaml:
pre-commit install --install-hooks --hook-type pre-commit --overwrite
# if you want to disable the hook
pre-commit uninstall --hook-type pre-commit
Code generation
After editing *_types.go or kubebuilder markers:
make generate
That also regenerates docs/crd.adoc from the API types. To
regenerate only the CRD reference:
make generate-crd-docs
When Calico Goldmane’s gRPC API changes, regenerate the vendored proto and Go stubs. protoc must be on your PATH. Default GOLDMANE_VERSION is v3.32.1 (same Calico version as e2e):
make generate-calico-goldmane-proto GOLDMANE_VERSION=v3.32.1
That downloads goldmane/proto/api.proto from the Calico repo into internal/scraper/goldmane/ and runs protoc. Override GOLDMANE_VERSION only when bumping Calico.
Verified environment
-
Go 1.27.1
-
kind 0.30.0
-
Providers installed by
setup-dev-cluster: Istio ambient 1.30.3, Calico v3.32.1, Cilium 1.20.0