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.

  • Docker

  • A C compiler (gcc or equivalent).

Steps

  1. Clone the repository:

    git clone https://github.com/kubewarden/network-enforcer.git
    cd network-enforcer
  2. Install kubectl, helm, kind, and tilt.

  3. Copy Tilt settings:

    cp tilt-settings.yaml.example tilt-settings.yaml
  4. Create a kind cluster with a provider and start Tilt. E2E_PROVIDER is istio, calico, or cilium:

    make setup-dev-cluster E2E_PROVIDER=istio

    This creates a kind cluster named kind, installs the provider and cert-manager, then runs tilt up. Tilt’s UI is typically http://localhost:10350.

  5. Check that the controller is up:

    kubectl get pods -n network-enforcer
    kubectl get workloadnetworkpolicyproposals.networkenforcer.kubewarden.io -A
  6. 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.

  1. 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-fix also downloads that binary into bin/.

  2. 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