operator/

directory
v0.1.5 Latest Latest
Warning

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

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

README

inkwall-operator

The Kubernetes operator (design). It:

  • validates WAFPolicy and rule set objects with a webhook: seclang rules must compile with the engine's Coraza version after the Core Rule Set, and only rule directives are allowed (0004 §3.1). It fails closed for the WAF kinds only; updates that don't change the spec are always accepted;
  • builds the policies and the Ingresses they target into a bundle, signed with the cluster's ed25519 key, in the inkwall-bundle Secret (leader only; a second after a change, and every 10 minutes), and reports Accepted on each policy. It rotates the 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/TLS on port 9445 and reports Enforced from their acknowledgements;
  • injects the engine as a native sidecar into Traefik pods at creation (selected by app.kubernetes.io/name=traefik, or InkwallConfig.spec.integrations[].selector), with the inkwall-trust ConfigMap and read access to the bundle. Opt a pod out with the label waf.inkwall.dev/inject: "false"; --inject=false turns injection off, and unwires the routes;
  • wires each targeted Ingress to an inkwall-waf ForwardAuth Middleware (prepended to traefik.ingress.kubernetes.io/router.middlewares) and reports Programmed. The waf.inkwall.dev/unwire finalizer keeps a deleted policy until its routes are unwired.

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

Install it with the Helm chart.

Develop

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

Target What
make generate Regenerate deepcopy code, CRDs, RBAC and webhook configuration, and copy them into the chart
make test Unit tests, operator tests against a local API server (envtest) at ENVTEST_K8S_VERSION, the oldest supported Kubernetes
make helm-lint Lint and render the chart
make kind-operator Build the images, install the chart on the kind cluster of make kind-up, check the webhook
make kind-e2e End to end on kind: a WAFPolicy enforced by an engine in bundle mode

To change the API: edit the types in api/v1alpha1/ (validation as kubebuilder markers, CEL in +kubebuilder:validation:XValidation), run make generate and commit the generated files, and 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 of each kind
manager/ Assembles 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, 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, Ingress annotation, Programmed
test/fakeengine/, test/testenv/ Fake engine speaking the bundle protocol; envtest API server

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).
Package integrations knows the proxies Inkwall wires into (0004 §4.2): how to recognise each one's IngressClass and pods, and which engine adapter its pods use.
Package integrations knows the proxies Inkwall wires into (0004 §4.2): how to recognise each one's IngressClass and pods, and which engine adapter its pods use.
internal
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.
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).
wiring
Package wiring sends a proxy's protected routes to the engine (0004 §4.4).
Package wiring sends a proxy's protected routes to the engine (0004 §4.4).
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