operator/

directory
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2026 License: Apache-2.0

README

inkwall-operator

The Inkwall Kubernetes operator (design). To install it, use the Helm chart. This page says what the operator does and how to develop it.

Contents

What it does

  • Validates WAFPolicy, WAFRuleSet and ClusterWAFRuleSet objects with a webhook. SecLang rules (seclang) must compile with the engine's Coraza version after the Core Rule Set, and only rule directives are allowed (0004 §3.1). The webhook fails closed, for the WAF kinds only, and always accepts updates that don't change the spec.
  • Builds the policies and the routes they target into a policy bundle, signed with the cluster's Ed25519 key, in the inkwall-bundle Secret. Past 900 KiB compressed, the bundle is split into chunk Secrets. The leader builds it a second after a change, and every 10 minutes, and reports Accepted on each policy. It rotates the signing key on request (the waf.inkwall.dev/rotate-signing-key annotation on the InkwallConfig) or on a schedule, without an engine ever rejecting a bundle.
  • Serves the bundle to the engines over gRPC with TLS on port 9445, and reports Enforced from their acknowledgements.
  • Injects the engine as a native sidecar into Traefik pods when they are created. It selects them by app.kubernetes.io/name=traefik, or by InkwallConfig.spec.integrations[].selector, and gives them the inkwall-trust ConfigMap and read access to the bundle. A pod labelled waf.inkwall.dev/inject: "false" is left alone. --inject=false turns injection off and unwires the routes.
  • Wires each targeted Ingress or IngressRoute to an inkwall-waf ForwardAuth Middleware, placed first in its middlewares, and reports Programmed. The waf.inkwall.dev/unwire finalizer keeps a deleted policy until its routes are unwired.
  • Connects to the optional control plane in GitOps and Managed mode (guide).

kubectl get wafpolicy -A shows READY once a policy is accepted, wired and enforced by every engine; the condition messages say what is missing (e.g. PendingRestart). Rules read from a ConfigMap need the label waf.inkwall.dev/rules=true. The operator creates and rotates a self-signed webhook certificate, in the inkwall-operator-webhook-tls Secret; with cert-manager, run it with --webhook-certs=external.

Develop

make help lists every target. The ones for the operator:

Target What it does
make generate Regenerates the deepcopy code, CRDs, RBAC and webhook configuration, and copies them into the chart
make test Unit tests, and operator tests against a local API server (envtest) at ENVTEST_K8S_VERSION, the oldest supported Kubernetes
make scale-test Checks the scale targets (0004 §8) with fake engines, in envtest
make helm-lint Lints and renders the chart
make kind-operator Builds the images, installs the chart on the kind cluster of make kind-up, and checks the webhook
make kind-e2e End to end on kind: a WAFPolicy enforced by an engine in bundle mode

To change the API:

  1. Edit the types in api/v1alpha1/: validation as kubebuilder markers, CEL rules in +kubebuilder:validation:XValidation.
  2. Run make generate, and commit the generated files.
  3. Add cases to api/v1alpha1/validation_test.go.

The CRDs validate on their own, without the operator:

kubectl apply --server-side -f operator/config/crd/bases -f operator/config/samples

Layout

Path What
api/v1alpha1/ waf.inkwall.dev/v1alpha1 types: InkwallConfig, WAFPolicy, WAFRuleSet, ClusterWAFRuleSet
config/ Generated CRDs, RBAC and webhook configuration (don't edit by hand); samples/ has one object of each kind
manager/ Assembles the controllers, webhooks and probes (../cmd/operator is the binary)
webhook/ Validating webhook and its certificate
integrations/ The proxies Inkwall knows (Traefik) and their pod selectors
resolver/ WAFPolicy + Ingresses and IngressRoutes + rule sets → bundle policies and Accepted (pure; inkwallctl test --policy uses it too)
bundle/ Content hash, versions, Ed25519 signing and key rotation, the bundle and signing key Secrets
internal/controller/ Bundle builder
internal/distribution/ BundleService server, engine authentication and reports, Enforced
internal/injection/ Engine sidecar, trust ConfigMap, RBAC grant
internal/wiring/ Traefik Middleware, route wiring, Programmed
internal/controlplane/ Connection to the optional control plane: enrollment, cluster state, events, Managed mode
internal/crdwatch/ Watches a kind whose CRD may be missing, such as Traefik's IngressRoute
test/fakeengine/, test/testenv/ Fake engine speaking the bundle protocol; envtest API server
test/fakecontrolplane/, test/stubcontrolplane/ Fake control plane for tests, and the server the kind end-to-end test runs it in
test/scale/ Scale test (make scale-test)

Directories

Path Synopsis
api
v1alpha1
Package v1alpha1 holds the Inkwall Kubernetes API (group waf.inkwall.dev): the cluster configuration, the policies app teams attach to their routes, and the rule sets those policies use.
Package v1alpha1 holds the Inkwall Kubernetes API (group waf.inkwall.dev): the cluster configuration, the policies app teams attach to their routes, and the rule sets those policies use.
Package bundle builds, signs and stores policy bundles (0004 §4.6).
Package bundle builds, signs and stores policy bundles (0004 §4.6).
config
rbac
Package rbac holds the operator's RBAC, generated from its kubebuilder:rbac markers (make generate).
Package rbac holds the operator's RBAC, generated from its kubebuilder:rbac markers (make generate).
Package enginereport reads the engines the operator's replicas report in their inkwall-engines-<pod> ConfigMaps (0004 §4.8): which engines are connected, the bundle each runs and the one it rejected.
Package enginereport reads the engines the operator's replicas report in their inkwall-engines-<pod> ConfigMaps (0004 §4.8): which engines are connected, the bundle each runs and the one it rejected.
Package integrations knows the proxies Inkwall wires into (0004 §4.2): how to recognise each one's IngressClass or GatewayClass and pods, and which engine adapter its pods use: Traefik, Envoy Gateway, Istio and the HAProxy Kubernetes Ingress Controller.
Package integrations knows the proxies Inkwall wires into (0004 §4.2): how to recognise each one's IngressClass or GatewayClass and pods, and which engine adapter its pods use: Traefik, Envoy Gateway, Istio and the HAProxy Kubernetes Ingress Controller.
internal
access
Package access tells which integrations the operator may wire (0004 §7).
Package access tells which integrations the operator may wire (0004 §7).
controller
Package controller holds the operator's reconcilers.
Package controller holds the operator's reconcilers.
controlplane
Package controlplane connects the operator to the optional control plane (0002 §3.4, §5.3, §7.5; api/controlplane/v1).
Package controlplane connects the operator to the optional control plane (0002 §3.4, §5.3, §7.5; api/controlplane/v1).
crdwatch
Package crdwatch watches a kind whose CRD may be missing, such as Traefik's IngressRoute: a controller can't start with a watch on a kind the API server doesn't serve, so the watch is added once it does.
Package crdwatch watches a kind whose CRD may be missing, such as Traefik's IngressRoute: a controller can't start with a watch on a kind the API server doesn't serve, so the watch is added once it does.
discovery
Package discovery finds the cluster's proxies (0004 §4.1): the controllers its IngressClasses and GatewayClasses name, and how far Inkwall wires each, in InkwallConfig.status.proxies.
Package discovery finds the cluster's proxies (0004 §4.1): the controllers its IngressClasses and GatewayClasses name, and how far Inkwall wires each, in InkwallConfig.status.proxies.
distribution
Package distribution serves bundles to the engines (0004 §4.7): every operator replica runs the BundleService, pushes each new bundle to its connected engines, and records what they applied.
Package distribution serves bundles to the engines (0004 §4.7): every operator replica runs the BundleService, pushes each new bundle to its connected engines, and records what they applied.
injection
Package injection gets the engine into a proxy's pods (0004 §4.3): a Pod webhook adds it as a native sidecar, and a controller provides what the sidecar needs in the pod's namespace (the trust ConfigMap) and in the operator's (read access to the bundle Secret).
Package injection gets the engine into a proxy's pods (0004 §4.3): a Pod webhook adds it as a native sidecar, and a controller provides what the sidecar needs in the pod's namespace (the trust ConfigMap) and in the operator's (read access to the bundle Secret).
podcache
Package podcache caches the proxy pods for the operator (0004 §4.3): one informer per integration's pod selector, read as one cache.
Package podcache caches the proxy pods for the operator (0004 §4.3): one informer per integration's pod selector, read as one cache.
policystatus
Package policystatus turns the WAFPolicies' conditions into metrics and Kubernetes Events (#378): the inkwall_operator_policies gauge counts the policies by condition, status and reason, and a change of a policy's Ready, Programmed or Enforced condition records an Event on it, so `kubectl describe wafpolicy` and event-based tooling see it.
Package policystatus turns the WAFPolicies' conditions into metrics and Kubernetes Events (#378): the inkwall_operator_policies gauge counts the policies by condition, status and reason, and a change of a policy's Ready, Programmed or Enforced condition records an Event on it, so `kubectl describe wafpolicy` and event-based tooling see it.
rollout
Package rollout replaces proxy pods that need a new engine, when the InkwallConfig asks for it (spec.engine.rollout: Automatic, #376): pods the Pod webhook would inject that run without the engine (started before Inkwall) or with an injected engine of another image than the one configured (an engine in the pod's own spec is the user's).
Package rollout replaces proxy pods that need a new engine, when the InkwallConfig asks for it (spec.engine.rollout: Automatic, #376): pods the Pod webhook would inject that run without the engine (started before Inkwall) or with an injected engine of another image than the one configured (an engine in the pod's own spec is the user's).
wiring
Package wiring sends a proxy's protected routes to the engine (0004 §4.4), through one Integration per proxy.
Package wiring sends a proxy's protected routes to the engine (0004 §4.4), through one Integration per proxy.
Package manager assembles the operator: the controllers and webhooks, in one controller-runtime manager.
Package manager assembles the operator: the controllers and webhooks, in one controller-runtime manager.
Package resolver turns the cluster's WAF objects into bundle policies (0004 §4.5): each WAFPolicy's targets are expanded into concrete host / path matches, its rule sets resolved, and conflicts between policies settled.
Package resolver turns the cluster's WAF objects into bundle policies (0004 §4.5): each WAFPolicy's targets are expanded into concrete host / path matches, its rule sets resolved, and conflicts between policies settled.
test
fakecontrolplane
Package fakecontrolplane is a control plane that implements api/controlplane/v1 for tests: enrollment with one-time tokens, client certificates from its own CA, and the Connect stream.
Package fakecontrolplane is a control plane that implements api/controlplane/v1 for tests: enrollment with one-time tokens, client certificates from its own CA, and the Connect stream.
fakeengine
Package fakeengine is a lightweight engine for operator tests (0004 §9): it speaks the bundle protocol, verifies each bundle's signature and acknowledges it, without inspecting any traffic.
Package fakeengine is a lightweight engine for operator tests (0004 §9): it speaks the bundle protocol, verifies each bundle's signature and acknowledges it, without inspecting any traffic.
stubcontrolplane command
Command stubcontrolplane runs the fake control plane (fakecontrolplane) as a server, for the end-to-end test on kind: it implements api/controlplane/v1 with its own CA, so this repository's tests never need a real control plane.
Command stubcontrolplane runs the fake control plane (fakecontrolplane) as a server, for the end-to-end test on kind: it implements api/controlplane/v1 with its own CA, so this repository's tests never need a real control plane.
testenv
Package testenv starts a local API server (envtest) with the Inkwall CRDs installed, for operator tests.
Package testenv starts a local API server (envtest) with the Inkwall CRDs installed, for operator tests.
Package webhook holds the operator's admission webhooks.
Package webhook holds the operator's admission webhooks.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL