---
title: WireGuard Encryption with Advanced Container Networking Services
description: An overview of Advanced Container Networking Services' WireGurard encryption capabilities on Azure Kubernetes Service (AKS).
author: josephyostos
ms.author: Josephyostos
ms.service: azure-kubernetes-service
ms.subservice: aks-networking
ms.topic: concept-article
ms.date:  09/11/2024
---

# In transit encryption with WireGuard

As organizations increasingly rely on Azure Kubernetes Service (AKS) to run containerized workloads, ensuring the security of network traffic between applications and services becomes essential especially in regulated or security-sensitive environments. In-transit encryption with WireGuard protects data as it moves between pods and nodes, mitigating risks of interception or tampering. WireGuard is known for its simplicity, and robust cryptography, offers a powerful solution for securing communication within AKS clusters. 

WireGuard encryption for AKS is part of the [Advanced Container Networking Services](advanced-container-networking-services-overview.md) feature set, and its implementation is based on [Cilium](https://docs.cilium.io/en/stable/security/network/encryption-wireguard/).


## WireGuard encryption scope  

WireGuard in-transit encryption in AKS is designed to secure specific traffic flows within your Kubernetes cluster. This section outlines which traffic types are encrypted and which aren't currently supported via Advanced Container Networking Services. 

Supported/Encrypted traffic flows: 
- Inter-node pod traffic: Traffic leaving a pod from one node destined to a pod on another node.

Unsupported/Unencrypted traffic flows 
- Same-node pod traffic: Traffic between pods on the same node 
- Node-network traffic: traffic generated by the node itself destined to another node  

## Architecture overview 

WireGuard encryption relies on  [Azure CNI powered by cilium](azure-cni-powered-by-cilium.md) to secure inter-node communications within a distributed system. The architecture uses a dedicated WireGuard agent that orchestrates key management, interface configuration, and dynamic peer updates. This section attempts to provide a detailed explanation 

:::image type="content" source="./media/advanced-container-networking-services/wireguard-design.png" alt-text="Diagram of WireGuard design." lightbox="./media/advanced-container-networking-services/wireguard-design.png":::

### WireGuard agent 

Upon startup, the Cilium agent evaluates its configuration to determine if encryption is enabled. When WireGuard is selected as the encryption mode, the agent initializes a dedicated WireGuard subsystem. The wireguard agent is responsible for configuring and initializing components required for enforcing WireGuard encryption. 

### Key generation 

A fundamental requirement to secure communication is the generation of cryptographic key pairs. Each node in the Kubernetes cluster will automatically generate a unique WireGuard key pair during the initialization phase and distributes its public key via the “network.cilium.io/wg-pub-key” annotation in the Kubernetes CiliumNode custom resource object. The key pairs are stored in memory and rotated every 120 seconds. The private key serves as the node’s confidential identity. The public key is shared with the peer nodes in the cluster to decrypt and encrypt traffic from and to Cilium-managed endpoints running on that node. These keys are managed entirely by Azure, not by the customer, ensuring secure and automated handling without requiring manual intervention. This mechanism ensures that only nodes with validated credentials can participate in the encrypted network.

### Interface creation 
Once the key generation process concludes, the WireGuard agent configures a dedicated network interface (cilium_wg0). This process involves interface creation and configuration with the previously generated private key. 

## Comparison with virtual network encryption  

Azure offers multiple options for securing in-transit traffic in AKS, including [virtual network level encryption](/azure/virtual-network/virtual-network-encryption-overview) and WireGuard-based encryption. While both approaches enhance the confidentiality and integrity of network traffic, they differ in scope, flexibility, and deployment requirements. This section helps you understand when to use each solution. 

**Use virtual network encryption when** 

- **You require full network-layer encryption for all traffic within the virtual network:** 
Virtual network encryption ensures that all traffic regardless of workload or orchestration layer is automatically encrypted as it traverses the Azure Virtual Network. 

- **You need minimal performance overhead:** 
Virtual network encryption uses hardware acceleration in supported VM SKUs, offloading encryption from the OS to the underlying hardware. This design delivers high throughput with low CPU usage. 

- **All your virtual machines support virtual network encryption:** 
Virtual network encryption depends on VM SKUs that support the necessary hardware acceleration. If your infrastructure consists entirely of supported SKUs, virtual network encryption can be seamlessly enabled. 

- **Your AKS Network configurations supports virtual network encryption:** 
Virtual network encryption has some limitations when it comes to aks pod networking. For more information, see [Virtual network encryption supported scenarios](/azure/virtual-network/virtual-network-encryption-overview#supported-scenarios)

**Use WireGuard encryption When**

- **You want to make sure that your application traffic is encrypted across all node** virtual network encryption does not encrypt traffic between nodes on the same physical host.

- **You want to unify encryption across multi-cloud or hybrid environments:** 
WireGuard offers a cloud-agnostic solution, enabling consistent encryption across clusters running in different cloud providers or on-premises. 

- **You don’t need or want to encrypt all traffic within the virtual network:** 
WireGuard enables a more targeted encryption strategy ideal for securing sensitive workloads without incurring the overhead of encrypting all traffic. 

- **Some of your VM SKUs don’t support virtual network encryption:** 
WireGuard is implemented in software and works regardless of VM hardware support, making it a practical option for heterogeneous environments. 

## Considerations & limitations 

•	WireGuard isn't [FIPS](https://csrc.nist.gov/pubs/fips/140-2/upd2/final) compliant.
•   WireGuard encryption doesn't apply to pods uses host networking (spec.hostNetwork: true) because these pods use the host identity instead of having individual identities.
> [!IMPORTANT]
> WireGuard encryption operates at the software level, which can introduce latency and impact throughput performance. The extent of this impact depends on various factors, including VM size (node SKU), network configuration, and application traffic patterns.
> Our benchmarking indicates that throughput is limited to 1.5 Gbps with an MTU of 1500; however, results may vary depending on workload characteristics and cluster configuration.
> Using a SKU that supports MTU 3900 resulted in approximately 2.5x higher throughput.
> While WireGuard encryption can be used alongside network policies, doing so may lead to further performance degradation, with reduced throughput and increased latency.
> For applications sensitive to latency or throughput, we strongly recommend evaluating WireGuard in a non-production environment first. As always, results may vary based on workload characteristics and cluster configuration.


## Pricing
> [!IMPORTANT]
> Advanced Container Networking Services is a paid offering. For more information about pricing, see [Advanced Container Networking Services - Pricing](https://azure.microsoft.com/pricing/details/azure-container-networking-services/).

## Next steps

- Learn how to apply [WireGuard encryption](how-to-apply-wireguard.md) on AKS.

- For more information about Advanced Container Networking Services for Azure Kubernetes Service (AKS), see [What is Advanced Container Networking Services for Azure Kubernetes Service (AKS)?](advanced-container-networking-services-overview.md).

- Explore Container Network Observability features in Advanced Container Networking Services in [What is Container Network Observability?](container-network-observability-metrics.md). 