Happy Dussehra! May good always win. Merry Christmas! Warm wishes from Vizag. Happy New Year! Here’s to a great year ahead.

DevOps · CNCF daily

Antrea: Kubernetes Networking and Network Policy on Open vSwitch

CNCF Sandbox. A Kubernetes-native CNI that uses Open vSwitch as its data plane to provide pod networking, tiered network policy, egress control and flow visibility.

8 min read

CNCF Sandbox

  • Antrea
  • Open vSwitch
  • Kubernetes
  • CNI
  • NetworkPolicy
CNCF project page

Antrea is a Kubernetes networking solution that implements the Container Network Interface (CNI) and Kubernetes NetworkPolicy using Open vSwitch (OVS) as the data plane. It operates at layers 3 and 4, gives every pod an address and connectivity across nodes, and adds security and visibility features beyond the standard NetworkPolicy API. It addresses the need for a CNI that is programmable, well suited to mixed Linux and Windows clusters, and familiar to teams that already operate virtual switches. Antrea was created at VMware (now Broadcom) and open-sourced in 2019. It joined the CNCF as a sandbox project on 28 April 2021, and the CNCF Landscape still lists it at the sandbox level.

CNCF daily · Sprint 2, day 5 · Cloud Native Network

At a glance

Category Runtime › Cloud Native Network
CNCF status Sandbox. Accepted April 28, 2021
Written in Go for the control and agent components; Open vSwitch (C) provides the data plane
License Apache 2.0
Data plane Open vSwitch, with Geneve, VXLAN or GRE tunnels, or no encapsulation on a routed network
Platforms Linux and Windows nodes; tested with Kubernetes 1.23 and later
Current release 2.7 (v2.7.0 is the latest tagged release at the time of writing)

Architecture

Antrea architecture: the Antrea Controller watches Pods, Namespaces and policies in the Kubernetes API and sends each node its policies; on every node the Antrea Agent receives CNI calls from antrea-cni and programs Open vSwitch flows, OVS connects the pod interfaces and tunnels to other nodes with Geneve or VXLAN, and the agent exports flow records to the Flow Aggregator.

Slate is Kubernetes, purple the Antrea components, grey the data plane and green flow export. The Controller runs once per cluster; everything inside the Node box runs on every node. Egress, multicast and encryption are implemented as additional flow rules and are not drawn. Open the zoomable diagram, or download it as SVG or PNG.

Component Responsibility
Antrea Controller A Deployment that watches Pods, Namespaces and policy resources, computes the effective policies, and sends each node only the policies that apply to its pods. It keeps its state in memory and needs no datastore.
Antrea Agent A DaemonSet on every node that sets up pod interfaces, allocates addresses, creates tunnels to other nodes and installs OVS flows.
antrea-cni The CNI plugin binary, invoked on pod creation and deletion through the container runtime; it passes each request to the local Agent.
Open vSwitch The ovs-vswitchd and ovsdb-server daemons that forward packets and enforce policy through flow tables.
Pod interfaces Virtual interfaces that attach each pod to the OVS bridge.
Tunnel Traffic to pods on other nodes is encapsulated with Geneve (the default), VXLAN or other tunnel types.
Flow Aggregator Receives connection records exported by each Agent, adds Kubernetes metadata and exports them to a collector such as Theia.

Design principle. Antrea uses Kubernetes machinery wherever possible: its Controller extends the Kubernetes API server library, authenticates through ServiceAccounts, and exposes its policies as custom resources. The data plane is a general-purpose programmable switch, so new features (egress, multicast, encryption) are added as flow rules rather than new kernel code.

From a policy to a flow rule and a tunnel

Antrea flow in eight steps: the controller watches the Kubernetes API, sends policy to the agent, antrea-cni passes CNI calls to the agent, the agent programs Open vSwitch, OVS attaches pod interfaces and builds tunnels to other nodes, and the agent exports flow records to the Flow Aggregator and a collector.

  1. Watch. The Controller watches Pods, Namespaces and policy resources in the Kubernetes API.
  2. Distribute policy. It computes the effective policies and sends each node only those that apply, over gRPC.
  3. CNI call. When a pod starts, the runtime calls antrea-cni, which passes the request to the local Agent.
  4. Program flows. The Agent allocates the pod’s address and installs OVS flows, including policy rules.
  5. Attach the pod. OVS connects the pod’s interface to the bridge.
  6. Tunnel. Traffic to pods on other nodes leaves through a Geneve or VXLAN tunnel to the OVS on that node.
  7. Export flow records. Each Agent exports connection records.
  8. Aggregate and export. The Flow Aggregator adds Kubernetes metadata and forwards the records to a collector.

Steps 1 to 6 happen when policies or pods change; steps 7 and 8 are optional and continuous.

Open the zoomable flow diagram, or download it as SVG or PNG.

Production reference design

A common deployment is a kubeadm, VMware or on-premises cluster, or a managed cluster where the provider’s default CNI is replaced or complemented.

  1. Check prerequisites. The Open vSwitch kernel module must be available on every node, and the cluster must allocate pod CIDRs per node (for kubeadm, set --pod-network-cidr).
  2. Install a pinned release with the manifest or the Helm chart:
    helm repo add antrea https://charts.antrea.io && helm repo update
    helm install antrea antrea/antrea -n kube-system --version 2.7.0
    kubectl -n kube-system rollout status ds/antrea-agent
  3. Enable features deliberately in the antrea-config ConfigMap. Examples are AntreaProxy to handle Services without kube-proxy, traffic encryption with IPsec or WireGuard between nodes, Egress and FlowExporter.
  4. Apply cluster-wide guardrails with tiered policy. Antrea’s ClusterNetworkPolicy evaluates in ordered tiers ahead of namespace-level NetworkPolicy:
    apiVersion: crd.antrea.io/v1beta1
    kind: ClusterNetworkPolicy
    metadata: { name: block-dev-to-data }
    spec:
      priority: 5
      tier: securityops
      appliedTo:
        - namespaceSelector: { matchLabels: { tier: data } }
      ingress:
        - action: Drop
          from:
            - namespaceSelector: { matchLabels: { env: dev } }
  5. Give selected workloads a stable source address with an Egress resource that points at an ExternalIPPool, so firewalls outside the cluster can allow-list traffic from specific applications:
    apiVersion: crd.antrea.io/v1beta1
    kind: Egress
    metadata: { name: egress-payments }
    spec:
      appliedTo:
        podSelector: { matchLabels: { app: payments } }
      externalIPPool: egress-pool

Typical uses include multi-tenant clusters that need platform-owned security rules, clusters with Windows worker nodes, on-premises clusters where applications need predictable source IPs for external firewalls, and teams that want connection-level flow records without a service mesh.

Operational considerations

  • Controller availability. The Controller runs as a single replica. Agents keep enforcing the last policies they received if it is down, but new or changed policies wait until it returns, so monitor it and let Kubernetes reschedule it quickly.
  • Kernel and node requirements. OVS needs its kernel module on every node image. Check this in your OS baseline and test node upgrades, because a kernel change can break the module.
  • Encapsulation and MTU. Tunnels reduce the usable MTU, and encryption reduces it further. Set the MTU explicitly, or use no-encapsulation mode on a routed network where the underlay allows it.
  • Policy ordering. Tiers and priorities decide which rule wins. Document the tier model (for example, security operations above application teams) and test changes with the Antrea policy tools before applying them cluster-wide.
  • Migration risk. Changing the CNI on a running cluster is disruptive. Plan it as a new cluster or a node-by-node migration with a rollback path, and do not mix two CNIs on one node.

Adoption

  • The project’s ADOPTERS.md lists Glasnostic, which uses Antrea’s Open vSwitch support to shape how services interact; Transwarp, which applies Antrea policies to protect big-data software for each tenant of its Kubernetes platform and uses the Egress feature to preserve source addresses; and TeraSky, which uses Antrea network policies and Egress in its internal clusters and for customers.
  • Antrea originated at VMware, and VMware’s Kubernetes offerings have used it as a default CNI, which gives it a large installed base in enterprise environments.
  • The published adopter list is short compared with larger CNI projects. Teams should check recent project activity and the support options of their platform vendor before choosing it.

Alternatives

Solution Model Best suited to
Cilium (CNCF Graduated) eBPF data plane with network policy, service mesh and observability The default choice for most new clusters; see the Cilium brief
Calico Routed networking with iptables or eBPF data planes and rich policy Teams wanting BGP-based, non-overlay networking and a large ecosystem
Kube-OVN (CNCF Sandbox) Open Virtual Network based, with VPC-style subnets Multi-tenant clusters that want per-tenant subnets and networks
Flannel Simple overlay with no policy engine Small clusters and labs that need basic connectivity only
Cloud VPC CNIs (AWS VPC CNI, Azure CNI) Pods receive addresses from the cloud network Managed clusters that need native VPC addressing and routing

Strengths and limitations

Strengths Limitations
Tiered, cluster-scoped policy gives platform teams guardrails above namespace rules Single-replica Controller; policy changes wait while it is down
Mature Windows node support alongside Linux Requires the OVS kernel module on every node
Egress, multicast, encryption and flow export built in Smaller community and adopter base than Cilium or Calico
Kubernetes-native design with in-memory state and no extra datastore A sandbox project, so governance and long-term support depend on its maintainers
Apache 2.0 with regular releases and good documentation Layer 3 and 4 focus; no built-in layer 7 policy or service mesh

Recommendation

Assess. Antrea is a capable CNI with strong policy features and clear value in clusters that mix Linux and Windows nodes, need tiered security rules owned by a platform team, or need predictable egress addresses. For most new general-purpose clusters, Cilium has the larger ecosystem and is the safer default. Evaluate Antrea in a test cluster against your policy and observability needs before committing production workloads.

References: CNCF project page · Antrea documentation · Antrea architecture · Antrea adopters · CNCF Landscape

Spotted something wrong or out of date?Suggest a correction. I review every suggestion before changing the page.

EmailRSS