Kubernetes WAF policy as code: how RevetmentPolicy attaches to a route
Kubernetes WAF policy as code means rules live in CRDs, not a console. See how RevetmentPolicy and RevetmentException attach to HTTPRoutes and move through Git.
A Kubernetes WAF policy as code model puts firewall rules into version-controlled manifests instead of web consoles. For teams running Envoy Gateway, RevetmentPolicy attaches security controls directly to Gateway API HTTPRoute resources, ensuring changes pass through pull requests and automated delivery pipelines.
Why WAF policy belongs in the same repo as the route
You run Envoy Gateway on Kubernetes, likely after migrating away from ingress-nginx. You own the ingress infrastructure and the edge routing. When an application team asks for a new route or modifies an existing path, that definition lives in an HTTPRoute resource committed to a Git repository. Yet, for many platform teams, the web application firewall configuration remains the last operational outlier. It is managed in a separate vendor portal, behind administrative logins, detached from the software delivery lifecycle.
Managing security controls through a web interface creates an operational fracture. In a console-first setup, an engineer clicks a button to disable an inspection rule at 2:00 AM during an outage. That change carries no git diff, no mandatory peer review, no automated test run, and no audit trail in the codebase. When the deployment pipeline reconciles an ingress manifest later that morning, the route changes, but nobody remembers why the inspection rule was disabled. The temporary bypass becomes permanent infrastructure drift.
Kubernetes WAF policy as code resolves this separation by declaring your firewall rules as Kubernetes objects stored alongside routing manifests. According to the Kubernetes custom resources documentation, CRDs allow platforms to extend cluster capabilities with custom APIs that integrate directly with core Kubernetes controllers. When your WAF configuration is a custom resource, the same continuous delivery pipeline that applies the HTTPRoute applies the security posture.
This approach introduces trade-offs you must accept. Managing security through CRDs means your firewall inherits every operational failure mode of GitOps WAF management. If your cluster reconciler encounters an invalid manifest schema, an out-of-order dependency, or a broken admission webhook, it may stall or silently leave the previous policy active. Revetment handles this mechanism through two custom resources: RevetmentPolicy and RevetmentException, both targeting HTTPRoutes through the standard Gateway API.
What a RevetmentPolicy object actually contains
A RevetmentPolicy CRD defines the security posture applied to an HTTPRoute. It does not act as a cluster-wide switch. Because it targets a specific routing object, two applications within the same cluster (or two paths on the same hostname) can run distinct security configurations without interfering with one another.
The policy dictates the inspection engine parameters, the paranoia level, and the enforcement state (shadow mode or active blocking). Revetment runs the OWASP Core Rule Set (CRS). Specifically, 477 of the pinned OWASP CRS v4.30.0 rule ids compile at paranoia level 1. The rules that do not load are named on /what-revetment-cannot-stop.
The manifest specifies intent for the Envoy process. Here is a structural YAML skeleton showing how the fields declare that intent:
apiVersion: revetment.io/v1alpha1
kind: RevetmentPolicy
metadata:
name: payments-api-waf
namespace: payment-apps
spec:
targetRef:
group: gateway.networking.k8s.io
kind: HTTPRoute
name: payments-api-route
ruleset:
crsVersion: "v4.30.0"
paranoiaLevel: 1
enforcement:
mode: Shadow # Values: Shadow, Active
promotionPercentage: 0 # Used during staged cutovers: 1, 10, 100
rollbackThreshold:
statusCodes5xxPercent: 5
Note: Confirm specific schema property names against the published CRD reference before deploying manifests to your clusters.
The CRD establishes an explicit boundary: it captures desired configuration in etcd, while the data plane handles execution. Revetment runs as a native module inside the Envoy process. It is not a sidecar, a WASM plugin, an ext_proc server, or a separate proxy. Because the inspection logic executes within the native Envoy data path, the data plane inspects requests inside your Envoy process and sends no traffic to Revetment. The hosted console is optional.
How the policy binds to an HTTPRoute through the Gateway API
Revetment attaches to Envoy Gateway through the Kubernetes Gateway API. It is not an ingress controller and does not run on NGINX, Traefik, HAProxy, or Istio. The attachment mechanism works by matching the targetRef in the RevetmentPolicy to the metadata.name and namespace of the destination HTTPRoute.
When Envoy Gateway translates Gateway API resources into dynamic xDS configurations, the Revetment controller watches for matching RevetmentPolicy objects. When a match occurs, the controller injects module metadata into the corresponding Envoy route filters. At request time, the in-process module queries this configuration to decide whether to evaluate rules in shadow mode or evaluate them for rejection.
This decoupling introduces a common operational trap. If an application team renames an HTTPRoute from payments-api-route to payments-v2-route in a pull request without updating the targetRef inside the policy manifest, the policy loses its binding. Envoy Gateway continues serving traffic to the application route, but the Revetment module no longer inspects those requests. The edge produces no error, and the endpoint runs without inspection.
To avoid this silent detachment, add a validation step to your continuous integration pipelines. A pipeline script can parse all HTTPRoute manifests within protected namespaces and verify that a matching RevetmentPolicy exists with a matching targetRef. If a developer renames a route without updating its policy, the pull request validation fails before the change reaches git main.
Exceptions as code: RevetmentException without disabling the rule
False positives are unavoidable when deploying CRS rules against production APIs. A standard web framework might transmit JSON payloads containing SQL fragments, Markdown syntax, or complex regex strings in form fields that trigger rule matches. The conventional response in legacy environments is disabling the offending CRS rule entirely across the application.
Disabling a rule globally creates wide security blind spots. If rule 942100 (SQL Injection Attack Detected via libinjection) triggers on an administrative search field, disabling that rule removes SQL injection inspection across every path on that domain. The bypass survives indefinitely because future developers lack the context or courage to re-enable it.
Revetment avoids global suppression through the RevetmentException CRD. Exceptions are scoped to a rule, a route, and a parameter. They are not a global rule disable. If rule 942100 fires legitimately on a query parameter named q under /search, the exception applies strictly to that parameter on that route. All other parameters on /search, and the entire remainder of the application, continue compiling and evaluating rule 942100.
apiVersion: revetment.io/v1alpha1
kind: RevetmentException
metadata:
name: allow-search-markdown
namespace: payment-apps
spec:
targetPolicy:
name: payments-api-waf
ruleId: 942100
scope:
pathPattern: "/api/v1/search"
parameterName: "filter"
location: Query # Values: Query, Header, Body
Managing exceptions as custom resources shifts security decisions into peer review. An exception cannot be introduced through an ad-hoc console click. A platform or application developer must open a pull request, articulate why the parameter triggers the rule, and commit the exception to the repository. For an in-depth breakdown of parameter parsing and exception workflows, see our dedicated guide on Envoy Gateway WAF exception management.
The GitOps loop: apply, observe, promote, revert
Managing WAF policies as code enables a predictable GitOps delivery loop. You commit a baseline policy, observe the results in shadow mode, tune exceptions via pull requests, and promote the route to active blocking.
Shadow mode records what a rule would have blocked and lets the request through. Blocking is a separate, per-route promotion. When you first bind a RevetmentPolicy to an HTTPRoute, the policy should define mode: Shadow . The Envoy module checks incoming requests against the many compiled PL1 rules, writes audit records when signatures match, but lets all traffic continue to the upstream backend.
This architecture keeps rule configuration in Git while pushing telemetry to an observation console. The policy and exception objects live in your Git repository. The shadow event records live in the Revetment console, which can be run hosted or self-hosted. The console groups shadow events by rule, route, parameter, and a redacted excerpt of the payload. The hosted console keeps 7 days on Free and 13 months on Pro. Self-hosted retention is yours to set.
Blocking is promoted per route in many, many, then many steps, with an automatic rollback threshold. The policy specifies a staged cutover. At many, the Envoy process randomly assigns many matching requests to active blocking enforcement; the remaining many continue in shadow mode. If the module encounters an unexpected surge of 5xx errors or rule rejections exceeding the rollbackThreshold, it rolls the route back to shadow mode automatically.
GitOps controllers such as Argo CD and Flux play a direct role in maintaining this state. As described in the Argo CD documentation, GitOps systems maintain application definitions by continuously reconciling cluster state with declarative Git sources. When using Flux, the reconciler checks manifests against the repository and reverts uncommitted changes introduced via the Kubernetes API.
This operational reality reveals a discipline requirement: every promotion step must be a Git commit. If an operator updates the promotion state directly through a console or by executing kubectl edit during an active deployment, the cluster diverges from Git. The next time Argo CD or Flux executes a reconciliation cycle, it will revert your manual change to match the repository. To promote safely, update the promotionPercentage value inside the version-controlled RevetmentPolicy file, submit the pull request, and let the reconciler apply the update.
Failure modes we have hit running this ourselves
Revetment is pre-GA. It runs in the operator's own production, but the site does not claim general availability or scale proof. In our own environment, the module runs across 18 of 18 policied routes, all blocking since 24 October 2026. You can review the operational snapshot on our production proof page. Running this architecture has surfaced several operational failure modes.
- Live edits diverge from version control. During an edge disruption, an engineer edited a policy object live in the cluster to bypass an inspection rule. Thirty minutes later, an automated pipeline merge applied an unrelated route change. The GitOps operator restored the unedited manifest from Git, re-enabling the blocked rule and resurrecting the failure. If an emergency change must happen in-cluster, push the commit to Git simultaneously.
- Out-of-order resource reconciliation can delay attachment. When deploying a new service alongside a new HTTPRoute and RevetmentPolicy, Kubernetes does not guarantee deployment ordering. If the RevetmentPolicy is processed before Envoy Gateway finishes building the HTTPRoute, the policy finds no valid target. The module logs a transient binding warning. The policy only attaches once the route enters a ready state and triggers a subsequent reconciliation event.
- Shadow mode is non-disruptive, which makes it easy to ignore. We have seen routes sit in shadow mode for over a month because no platform engineer was assigned to inspect the console's event logs. Teams assumed the application was secure simply because a RevetmentPolicy manifest existed in the repository, when in fact the route was blocking zero attacks.
- Parameter exceptions written too quickly can accumulate. If five microservices handle identical pagination parameters and experience identical false positives, platform teams may end up writing five distinct RevetmentException objects instead of standardizing the input validation or tuning the upstream client library. Exceptions must be audited on a fixed schedule.
What this model cannot do
Clear security design requires explicit boundaries. Revetment focuses strictly on application-layer inspection inside Envoy Gateway. It does not replace other layers of your infrastructure.
Revetment is an L7 WAF. It does not absorb DDoS traffic, protect DNS, or act as a scrubbing network; use an edge CDN or DDoS service for that. Volumetric traffic attacks intended to saturate network bandwidth must be stopped before they hit your ingress nodes.
Revetment does not implement rate limiting, slowloris protection, HTTP/2 rapid-reset budgets, or concurrency limits. Those functions belong in Envoy Gateway's native rate limiting filters or upstream infrastructure components designed for connection pooling and request throttling.
Revetment does not sell bot management, device fingerprinting, account-takeover protection, or credential-stuffing protection. Automated scraping frameworks and sophisticated credential attacks require dedicated identity protections and client-side interrogation tools.
Revetment matches known signatures. A genuinely novel exploit passes until a rule for it exists and reaches the deployment; no signature WAF can promise otherwise. If an exploit exploits unknown application logic without matching the 477 compiled CRS v4.30.0 patterns, the module will not detect it.
No WAF can promise complete detection or zero false positives. Revetment's workflow is built to show the false positives before blocking. Revetment publishes no latency or throughput benchmark.
Organizationally, SSO (SAML/OIDC) and roles are planned for Q1 2027 on Pro. They are not available today. Manage access to your cluster manifests using standard Kubernetes RBAC and Git provider permissions.
A review checklist before you merge the first policy
Before submitting the pull request that binds your first RevetmentPolicy to an HTTPRoute, walk through this checklist to ensure your delivery pipeline and operational boundaries are prepared:
- Check that the
targetRef.nameand namespace match the target HTTPRoute exactly. Run your CI route-validation check to confirm the binding is sound. - Ensure the manifest sets
mode: ShadowwithpromotionPercentage: 0. Do not configure a new route to block on its initial merge. - Name the engineer responsible for checking the console during the observation window. Shadow mode provides value only when someone reviews the matched rules and payload excerpts.
- If your testing requires a RevetmentException, confirm it specifies the rule ID, path pattern, parameter name, and request location. Document the business rationale in the Git commit description.
- Ensure the rollbackThreshold is populated in the policy. When you later promote through many, many, and many, the data plane must know the error percentage that triggers an automatic fallback to shadow mode.
- Check the installation documentation for your specific cloud environment on our installation directory. Each install guide states its own validation status; describe only the providers whose guide is marked verified.
- Review cost structures. Pricing is per cluster, never per request, rule, route, or user. The Free, Pro, and Enterprise tiers are listed on /pricing.
The policy is the artifact, the console is the window
Kubernetes WAF policy as code shifts your firewall configuration out of manual administrative panels and into version control. The custom resource in Git is the authoritative source of truth. The console exists only to surface what the policy observed, highlight false positives, and display redacted excerpts so you can write precise exceptions.
Adopting this model requires disciplined engineering habits. You must manage promotion steps through commits, add validation tests to your pipelines, and inspect shadow events regularly. Revetment is not open source. The Helm chart and the four images are Apache-2.0. The source repository is private. Revetment is pre-GA, and support is best effort from one maintainer, with no SLA on any tier.
Frequently asked questions
Is a Kubernetes WAF policy as code the same as a ConfigMap-driven WAF?
No. ConfigMaps simply store arbitrary text or configuration snippets. They do not validate schemas, manage lifecycle states, or offer structural status conditions. A custom resource definition like RevetmentPolicy uses the Kubernetes API machinery to validate input schemas, enforce parameter rules, and bind explicitly to Gateway API resources like HTTPRoutes. Status updates and promotion metrics report back through standard Kubernetes object fields.
Can I manage RevetmentPolicy objects with Argo CD or Flux?
Yes. RevetmentPolicy and RevetmentException are standard Kubernetes custom resources. You store the manifests in your Git repositories alongside your HTTPRoutes or application charts. Your continuous delivery tools apply and reconcile them based on your existing sync policies. Because controllers reconcile state continuously, manual modifications applied directly to the cluster will be reverted to match Git.
What happens to a route if the RevetmentPolicy is deleted?
If you delete a RevetmentPolicy, the Envoy Gateway controller removes the module inspection metadata from that specific route's filter chain. Traffic to the upstream service continues flowing through Envoy without interruption, but request inspection stops immediately. The application returns to an uninspected baseline.
Do exceptions in RevetmentException disable a rule everywhere?
No. Exceptions are scoped to a rule, a route, and a parameter. They are not a global rule disable. If you write an exception for rule 942100 on the filter parameter of an HTTPRoute, the rule remains active for every other parameter on that route and across all other routes in your cluster.
Does the hosted console see my request traffic?
No. Revetment runs as a native module inside the Envoy process. It is not a sidecar, a WASM plugin, an ext_proc server, or a separate proxy. The data plane inspects requests inside your Envoy process and sends no traffic to Revetment. The hosted console is optional. The module transmits only anonymized, redacted event excerpts when a rule matches, showing the specific rule, route, and parameter involved.
Read the install guide for your provider, apply a single RevetmentPolicy to one HTTPRoute in shadow, and read the events before you promote anything, then check /proof to see the same loop running on our own routes.