This is unreleased documentation for Network Enforcer 0.5-dev.

Configuring Kubewarden Network Enforcer for production

For the provider and Kubernetes requirements, see Compatibility. For how the components work together, see Architecture. For the debug tools, see Troubleshooting.

Controller

The controller runs as a Kubernetes Deployment with leader election. One replica is active at a time. It reads flows from the data plane, writes proposals and policies, and updates the policy status.

The controller also serves a validating admission webhook. An outage blocks WorkloadNetworkPolicy creates and updates, including mode changes. Learning and status updates stop, but existing native policy objects remain enforced.

The Kubernetes API server must reach the webhook Service over HTTPS. The chart requires cert-manager and its CSI driver for certificates. See Admission webhook.

Controller replicas

controller.replicas defaults to 1. Only the leader does the work. An extra replica is a warm standby. It shortens the failover time, and it does not add throughput.

On Istio, only the leader polls the agents. To keep a standby replica with any provider, set:

controller:
  replicas: 2

Schedule the controller

Use controller.tolerations, controller.nodeSelector, and controller.affinity to control where the controller pods run. For example, spread two replicas across different nodes with podAntiAffinity. This example matters only when controller.replicas is more than 1:

controller:
  affinity:
    podAntiAffinity:
      preferredDuringSchedulingIgnoredDuringExecution:
        - weight: 100
          podAffinityTerm:
            labelSelector:
              matchLabels:
                app.kubernetes.io/component: controller
            topologyKey: kubernetes.io/hostname

Set controller resources

controller.resources defaults to a Guaranteed 100m CPU and 256Mi memory, with the same requests and limits. The memory of the controller grows with the number of distinct flows and the number of proposals in the cluster. Watch the controller pod after the install, and raise both values when the pod gets close to its limit. Keep requests equal to limits, so that the pod keeps the Guaranteed class:

controller:
  resources:
    limits:
      cpu: 250m
      memory: 512Mi
    requests:
      cpu: 250m
      memory: 512Mi

Keep the status sync interval

controller.wnpStatusUpdateInterval defaults to 30s. The quick start lowers it to make the demo responsive. A shorter interval writes the policy status more often and adds load on the API server. In production, keep the default. See wnpStatusUpdateInterval latency for what the interval changes.

Add a PodDisruptionBudget for the controller

A PodDisruptionBudget (PDB) limits how many pods a voluntary disruption can remove at the same time, for example a node drain or a cluster upgrade. The chart ships a PDB template for the controller, off by default.

Set minAvailable or maxUnavailable under controller.podDisruptionBudget:

controller:
  podDisruptionBudget:
    minAvailable: 1

If controller.replicas is 1 and controller.podDisruptionBudget.minAvailable is 1, the PodDisruptionBudget blocks every voluntary disruption of the controller pod, including kubectl drain. Before you turn on the PodDisruptionBudget, set controller.replicas to 2 or more.

Istio agent DaemonSet

Schedule an agent on every ztunnel node, including tainted nodes. Without an agent, the controller misses connections and violations on that node. Ztunnel still enforces existing policies.

Set resources, tolerations, nodeSelector, and affinity under controller.provider.istio.agent. By default the agent tolerates all taints. If you narrow its placement, compare the nodes for both DaemonSets. The cert-manager CSI driver must also run on those nodes.

Allow the controller to reach agent pod IPs on TCP port 50052, or the port in controller.provider.istio.agent.grpcPort. The chart does not restrict that port with a NetworkPolicy.

controller.provider.istio.agent.enabled: false disables the chart’s DaemonSet, not polling or mutual TLS. For agents that you manage separately, match the chart’s namespace, discovery labels, port, and certificate identities.

The controller flags --agent-poll-interval (default 5s) and --agent-scrape-timeout (30s) control polling. --agent-max-in-flight limits concurrent scrapes and event processing. The default is 2.

Agent log access

The agent runs as root to read the node’s logs. It mounts /var/log/pods and /var/log/containers read-only. It reads .log files under /var/log/pods/istio-system_ztunnel-*/, in the ztunnel or istio-proxy container directory. If your ztunnel runs outside istio-system, its logs do not match these paths.

The agent drops all Linux capabilities and does not mount a service account token. The host mounts still require a Pod Security Admission exemption or the privileged level for the namespace. See Admission policies and Pod Security Admission.

PriorityClass

The chart creates a PriorityClass named network-enforcer-priorityclass, with value 1000000, and applies it to the controller and agent pods. The scheduler gives these pods priority over most application pods.

To reuse an existing PriorityClass, for example system-cluster-critical, turn off the chart-managed one and point priorityClass.name at the existing class:

priorityClass:
  enabled: false
  name: system-cluster-critical

If you delete a PriorityClass, running pods that use it keep running. New pods that name the deleted class do not start.

Admission policies and Pod Security Admission

What an admission policy accepts depends on the provider.

With Calico or Cilium, the chart deploys only the controller. Its pods run as non-root, drop all capabilities, and use no host namespace or hostPath volume. They meet the restricted Pod Security Admission level, and none of the Kubewarden Admission Controller recommended policies rejects them. The Network Enforcer namespace can carry pod-security.kubernetes.io/enforce: restricted.

With the Istio provider, the agent pod fails both the baseline and the restricted level. In protect mode, two of the Admission Controller recommended policies reject it:

Policy Why it rejects the agent

do-not-share-host-paths

The agent mounts /var/log/pods and /var/log/containers from the host.

do-not-run-as-root

runAsUser is 0 and runAsNonRoot is false.

Exclude the Network Enforcer namespace from these policies, with the recommendedPolicies.skipAdditionalNamespaces value of the Admission Controller Helm chart. The default exclusion list of that chart does not include a Network Enforcer namespace, so add yours in every case:

recommendedPolicies:
  skipAdditionalNamespaces:
    - network-enforcer

Keep the namespace at the privileged Pod Security Admission level, or use audit or warn mode only.

See Security hardening for the full list of recommended policies, and Pod Security Admission for the three levels.

Telemetry

To export violations, set otel.endpoint to your collector’s OTLP/gRPC endpoint. The chart does not install a collector. Only the controller will use this endpoint.

otel:
  endpoint: https://otel-collector.observability.svc.cluster.local:4317
  caSecretName: otel-collector-ca

If the collector uses a private CA, put its certificate in the ca.crt key of otel.caSecretName in the release namespace. For a collector that requires mutual TLS, set otel.clientCertificateSecretName to a Secret with tls.crt and tls.key.

Learning scope

The chart has no value that limits the learning scope. Learning is cluster-wide and starts when the controller starts. The provider decides which flows the controller sees:

  • With the Istio provider, only the namespaces that carry the label istio.io/dataplane-mode=ambient send traffic through ztunnel. That label is the learning scope.

  • With the Calico or the Cilium provider, every flow that the data plane reports is learned, in every namespace.

Learning stops for a workload and direction when a WorkloadNetworkPolicy with the same name exists. You can learn the policies in another cluster, for example staging, promote them there, and apply the resulting policies to production as code. The controller then writes a WorkloadNetworkPolicyProposal only for the workloads that have no policy yet.

See Learning does not reconstruct past traffic for what learning does not record.

Keep the flow dumper off

controller.flowDumper.enabled defaults to false. Keep it off in production. When it is on, the chart creates a NodePort Service on port 30080 that exposes the raw flow records on every node. Turning it on or off also changes the controller arguments, so the controller restarts.

See Flow dumper for what it shows and how to read it.

Example production configuration

This example combines the configuration from this page into one Helm values file, for the Istio provider:

controller:
  provider:
    name: istio
  replicas: 2
  podDisruptionBudget:
    minAvailable: 1
  resources:
    limits:
      cpu: 250m
      memory: 512Mi
    requests:
      cpu: 250m
      memory: 512Mi
  wnpStatusUpdateInterval: 30s
  flowDumper:
    enabled: false

otel:
  endpoint: https://otel-collector.observability.svc.cluster.local:4317
  caSecretName: otel-collector-ca

For Calico or Cilium, change controller.provider.name to calico or cilium.

Use a chart that includes controller.provider.istio.agent in its values. For the development chart, see Install the chart. For a published chart with the agent, apply the values file at install time:

helm upgrade --install network-enforcer kubewarden/network-enforcer \
  --namespace network-enforcer \
  --create-namespace \
  -f production-values.yaml \
  --wait