|
This is unreleased documentation for Network Enforcer 0.5-dev. |
Kubewarden Network Enforcer architecture
The Kubewarden Network Enforcer controller learns from flow records that the data plane already produces. On Istio, a node agent reads the ztunnel logs. On Calico and Cilium, the controller reads the provider API directly. The controller writes a proposal for the traffic it sees. When you promote the proposal, the controller creates a native policy. The data plane enforces the policy in protect mode.
The introduction explains why the enforcer learns from the data plane. The Phases page explains the learn, monitor, and protect lifecycle. This page explains how the parts fit together.
Design principles
Observe before you enforce
Observation is always on and has no side effect. Enforcement is a label that you set on one resource. Nothing blocks traffic until you ask.
Learn from the data plane, do not add one
The flow records already exist. ztunnel, Goldmane, and Hubble Relay produce them. Network Enforcer does not add a proxy or an eBPF probe to the traffic path.
One model, three providers
A proposal and a policy have the same shape on every provider. The provider changes the flow source that the controller reads and the backend that it writes. The learn, monitor, and protect workflow does not change.
Promotion is a label, not a side effect
The controller never turns a proposal into a policy on its own. You set the
networkenforcer.kubewarden.io/promote. A reviewer can read the proposal, approve it, and keep
the approval in Git.
The native object is the policy
In protect mode, the thing that blocks traffic is an
AuthorizationPolicy or a NetworkPolicy. You read it, diff it,
and debug it with the tools of the data plane. Network Enforcer owns the
object and keeps it in sync, but it adds no format of its own.
The Kubewarden Network Enforcer stack
Controller
The controller is a Deployment with leader election, so one replica is active at a time. The active replica runs five parts in one process.
-
The scraper reads the flow source of the selected provider. It turns each flow into a learning event or a violation observation. It does not write Kubernetes objects.
-
The learning reconciler turns learning events into
WorkloadNetworkPolicyProposalresources, one per workload and direction. -
The proposal reconciler watches the promote label. It creates the
WorkloadNetworkPolicy, sets the promoted-from label, and deletes the proposal. -
The policy reconciler renders each policy as a native policy object and keeps it in sync.
-
The status sync writes the buffered violation observations to the policy status on a timer, the status sync interval.
The controller also exports the violation events to the OpenTelemetry collector, when the export is on.
ztunnel log reader
On Istio, the chart runs a Network Enforcer agent on each node that runs ztunnel.
The agent reads new JSON log lines and keeps learning events and policy violations in memory.
The controller leader finds the agent pods by label in its namespace. It polls each pod IP over gRPC with mutual TLS.
The default port is 50052. After a successful poll, the leader waits about five seconds before it polls that agent again.
Each agent holds up to 10,000 events. If the buffer fills, new events replace the oldest ones. A scrape drains the buffer before the agent replies. If the reply is lost, the agent cannot send those events again. Restarting the agent also clears its buffer. Neither a missed scrape nor an agent restart changes what ztunnel enforces.
OpenTelemetry collector
The controller can send violation events to your OpenTelemetry collector over OTLP.
The chart does not install a collector. Leaving otel.endpoint empty turns off export, not learning or policy status updates.
Flow sources
The flow source depends on the provider:
-
Istio ambient: the agent reads the JSON access and authorization logs of ztunnel. Ztunnel sees inbound TCP only, so it creates ingress proposals.
-
Calico: the Goldmane flow service, over gRPC with mutual TLS. Goldmane reports both ends of a connection, so learning creates an egress proposal on the source and an ingress proposal on the destination.
-
Cilium: the
GetFlowsstream of Hubble Relay, over gRPC with TLS by default. Hubble reports both ends too.
A flow with one end outside the cluster, or on a pod with hostNetwork, is
dropped. See Known limitations.
Validating Admission Policies
The chart installs two
Validating Admission
Policies. One rejects a promote label whose value is not monitor or
protect. One rejects a change to the owner reference of a proposal, so
that a proposal stays tied to its workload.
Validating admission webhook
The controller also serves a webhook that checks policy target uniqueness.
It fails closed for WorkloadNetworkPolicy creates and updates.
Proposal writes, policy deletes, and status updates are outside its scope.
An outage does not stop enforcement of existing native policies. See
Controller availability.
Providers and backends
The Helm value controller.provider.name selects the provider once, at
installation. The provider selects the flow source and the backend.
| Provider | Flow source | Backend and native object |
|---|---|---|
|
ztunnel logs from the node agent, gRPC on port |
|
|
Goldmane, gRPC with mutual TLS |
|
|
Hubble Relay, gRPC with TLS by default |
|
controller.provider.istio.agent.grpcPort sets the port on both the agent and the controller.
Calico and Cilium use controller.provider.calico.endpoint and controller.provider.cilium.endpoint respectively.
The spec.backend field of a proposal or policy cannot change after
creation.
What runs where
| Place | Work |
|---|---|
Controller leader |
Flow scraping. Learning, promotion, and policy rendering. Status sync. Event export. |
Every node, Istio provider only |
The agent reads local ztunnel logs and holds events until the leader polls it. |
Data plane |
Enforcement of the native policy object. On Istio, ztunnel also evaluates the dry-run policy in monitor mode and logs the result. |
Workload targeting
Policies and proposals require spec.targetRef (workload kind and name)
and spec.direction. The target is a Deployment, StatefulSet, or DaemonSet
in the same namespace. The direction is Ingress or Egress, with
Ingress only for Istio.
Only one policy can target a workload and direction in a namespace. That policy holds all rules for that direction. Its selector still controls which pods the native policy selects. It must match the target workload’s pod template without matching another workload’s template.
The controller checks duplicates and selector scope on reconciliation. See Policy targeting for conditions and corrective actions.
The journey of a policy
This section follows one workload from the first observed flow to a written violation record.
-
A flow is observed. The data plane records a connection between two workloads. The scraper reads the record, resolves both ends to a workload through the Kubernetes API, and emits a learning event. If a policy already exists for that workload and direction, it emits a violation observation instead.
-
The controller writes a proposal. The learning reconciler creates or updates the
WorkloadNetworkPolicyProposalfor the workload and the direction. The name is the kind, the name, and the direction of the workload, for exampledeployment-http-server-ingress. The proposal lists the peers, protocols, and ports. It is owned by the workload, so Kubernetes deletes it with the workload. Nothing is enforced. -
You promote the proposal. You set the promote label to
monitororprotect. The proposal reconciler creates aWorkloadNetworkPolicywith the same name, namespace, target, direction, and backend spec. It setsspec.modefrom the label and sets the promoted-from label. Then it deletes the proposal. If the scraper creates the proposal again, the reconciler deletes it as a leftover. -
The controller renders the native object. The policy reconciler creates an object with the same name and namespace as the policy, and an owner reference to it. What it creates depends on the backend and the mode:
Backend Monitor Protect istioAn
AuthorizationPolicywith the annotationistio.io/dry-run: "true". ztunnel evaluates it and logs the decision. Traffic is not blocked.The same
AuthorizationPolicywithout the annotation. Traffic is blocked.kubernetesNo object. The controller compares each observed flow with
spec.kubernetesin software. Traffic is not blocked.A
NetworkPolicybuilt fromspec.kubernetes. The CNI blocks traffic. -
The data plane acts. In monitor mode, the flow passes. In protect mode, the data plane drops it, and the connection fails with a timeout, a reset, or a refusal.
-
A violation is observed. On Istio, ztunnel logs a dry-run match in monitor mode and a denial in protect mode. On Calico and Cilium, the scraper sees a flow that the policy does not allow, or a dropped flow with a policy as the reason. In each case the scraper emits a violation observation. The controller buffers it. If export is on, it also sends a
policy_violation_observedevent to the collector. -
The status is written. On the next status sync, the controller merges the buffered observations into the policy status. It gives each new record an
id, keeps the 100 most recent records instatus.violations, and updatesstatus.violationCountandstatus.activeViolationCount. The violation record is now visible tokubectl.
A mode change
When you change spec.mode, the policy reconciler updates the native
object. On Istio, it adds or removes the dry-run annotation. On Calico and
Cilium, it creates or deletes the NetworkPolicy. No pod restarts.
An acknowledgement
When you add the networkenforcer.kubewarden.io/acknowledge-<id> with a reason, the status
sync moves the record to status.acknowledgedViolations, removes the
annotation, and sends a policy_violation_acknowledged event.
What the status tells you
The status holds the 100 most recent active records and the 100 most recent
acknowledged records. The counter violationCount grows with each
observation that the controller scrapes, so it can exceed the number of
distinct records. The field activeViolationCount equals the number of
records in status.violations.
The controller resolves the subject workload through pod owner references. It first checks a reported enforcing object’s owner against that subject. Otherwise, it looks up the policy by target and direction.
Attributed violations appear in status on the next status sync.
Unattributed observations do not enter policy status. They increment
network_enforcer_violations_unattributed_total and still produce
OpenTelemetry logs when export is enabled.
On Istio, the destination port of a violation record is always 0, because ztunnel does not report it in the policy log.
Trust boundaries
-
The chart uses cert-manager and its CSI driver for the admission webhook and the Istio agent connection. Each agent checks the controller’s certificate. The controller checks the agent’s certificate against the pod name and namespace.
-
The OpenTelemetry collector uses separate credentials. Its certificate does not authenticate an Istio agent.
-
Goldmane requires mutual TLS. The controller reads the client key pair and the CA bundle that Calico creates in its own namespace. There is no plain-text option.
-
Hubble Relay uses TLS by default, with a client certificate that Cilium creates. A plain-text connection is a choice that you make at installation.
-
For Calico and Cilium, the TLS mode selects how the controller authenticates the provider. With
issuer, cert-manager writes them into the pod. WithexistingSecret, the controller reads a Secret that already exists, in its own namespace or in the namespace of the provider. The Provider TLS table lists the default mode and the Secret of each provider. -
The controller is the only writer of proposals, policies, policy status, and native policy objects. No component writes a Pod.
-
The two Validating Admission Policies fail closed. A promote label with a wrong value, or a change to the owner of a proposal, is rejected.
How Kubewarden Network Enforcer scales
On Istio, the agents read logs in parallel on their nodes. The leader polls up to two agents at a time by default. Adding a controller replica gives the leader a standby. It does not increase the number of events the leader can process.
The status of each policy is capped at 100 records, so a loud workload does not grow the API object without bound. For a longer history, export events to a collector with persistent storage.
The controller adds no cost to the data path. In protect mode, the data plane enforces the native object on its own. If the controller stops, the policies that it rendered stay in place.