|
| 1 | +--- |
| 2 | +title: Configure Azure CNI Powered by Cilium in Azure Kubernetes Service (AKS) (Preview) |
| 3 | +description: Learn how to create an Azure Kubernetes Service (AKS) cluster with Azure CNI Powered by Cilium. |
| 4 | +services: container-service |
| 5 | +ms.topic: article |
| 6 | +ms.custom: references_regions |
| 7 | +ms.date: 10/24/2022 |
| 8 | +--- |
| 9 | + |
| 10 | +# Configure Azure CNI Powered by Cilium in Azure Kubernetes Service (AKS) (Preview) |
| 11 | + |
| 12 | +Azure CNI Powered by Cilium combines the robust control plane of Azure CNI with the dataplane of [Cilium](https://cilium.io/) to provide high-performance networking and security. |
| 13 | + |
| 14 | +By making use of eBPF programs loaded into the Linux kernel and a more efficient API object structure, Azure CNI Powered by Cilium provides the following benefits: |
| 15 | + |
| 16 | +- Functionality equivalent to existing Azure CNI and Azure CNI Overlay plugins |
| 17 | +- Faster service routing |
| 18 | +- More efficient network policy enforcement |
| 19 | +- Better observability of cluster traffic |
| 20 | +- Support for larger clusters (more nodes, pods, and services) |
| 21 | + |
| 22 | +[!INCLUDE [preview features callout](./includes/preview/preview-callout.md)] |
| 23 | + |
| 24 | +## IP Address Management (IPAM) with Azure CNI Powered by Cilium |
| 25 | + |
| 26 | +Azure CNI Powered by Cilium can be deployed using two different methods for assigning pod IPs: |
| 27 | + |
| 28 | +- assign IP addresses from a VNet (similar to existing Azure CNI with Dynamic Pod IP Assignment) |
| 29 | +- assign IP addresses from an overlay network (similar to Azure CNI Overlay mode) |
| 30 | + |
| 31 | +> [!NOTE] |
| 32 | +> Azure CNI Overlay networking currently requires the `Microsoft.ContainerService/AzureOverlayPreview` feature and may be available only in certain regions. For more information, see [Azure CNI Overlay networking](./azure-cni-overlay.md). |
| 33 | +
|
| 34 | +If you aren't sure which option to select, read ["Choosing a network model to use"](./azure-cni-overlay.md#choosing-a-network-model-to-use). |
| 35 | + |
| 36 | +## Network Policy Enforcement |
| 37 | + |
| 38 | +Cilium enforces [network policies to allow or deny traffic between pods](./operator-best-practices-network.md#control-traffic-flow-with-network-policies). With Cilium, you don't need to install a separate network policy engine such as Azure Network Policy Manager or Calico. |
| 39 | + |
| 40 | +## Limitations |
| 41 | + |
| 42 | +Azure CNI powered by Cilium currently has the following limitations: |
| 43 | + |
| 44 | +* Available only for new clusters. |
| 45 | +* Available only for Linux and not for Windows. |
| 46 | +* Cilium L7 policy enforcement is disabled. |
| 47 | +* Hubble is disabled. |
| 48 | +* Kubernetes services with `internalTrafficPolicy=Local` aren't supported ([Cilium issue #17796](https://github.com/cilium/cilium/issues/17796)). |
| 49 | +* Multiple Kubernetes services can't use the same host port with different protocols (for example, TCP or UDP) ([Cilium issue #14287](https://github.com/cilium/cilium/issues/14287)). |
| 50 | +* Network policies may be enforced on reply packets when a pod connects to itself via service cluster IP ([Cilium issue #19406](https://github.com/cilium/cilium/issues/19406)). |
| 51 | + |
| 52 | +## Prerequisites |
| 53 | + |
| 54 | +* Azure CLI version 2.41.0 or later. Run `az --version` to see the currently installed version. If you need to install or upgrade, see [Install Azure CLI][/cli/azure/install-azure-cli]. |
| 55 | +* Azure CLI with aks-preview extension 0.5.109 or later. |
| 56 | +* If using ARM templates or the REST API, the AKS API version must be 2022-09-02-preview or later. |
| 57 | + |
| 58 | +### Install the aks-preview CLI extension |
| 59 | + |
| 60 | +```azurecli-interactive |
| 61 | +# Install the aks-preview extension |
| 62 | +az extension add --name aks-preview |
| 63 | +
|
| 64 | +# Update the extension to make sure you have the latest version installed |
| 65 | +az extension update --name aks-preview |
| 66 | +``` |
| 67 | + |
| 68 | +### Register the `CiliumDataplanePreview` preview feature |
| 69 | + |
| 70 | +To create an AKS cluster with Azure CNI powered by Cilium, you must enable the `CiliumDataplanePreview` feature flag on your subscription. |
| 71 | + |
| 72 | +Register the `CiliumDataplanePreview` feature flag by using the `az feature register` command, as shown in the following example: |
| 73 | + |
| 74 | +```azurecli-interactive |
| 75 | +az feature register --namespace "Microsoft.ContainerService" --name "CiliumDataplanePreview" |
| 76 | +``` |
| 77 | + |
| 78 | +It takes a few minutes for the status to show *Registered*. Verify the registration status by using the `az feature list` command: |
| 79 | + |
| 80 | +```azurecli-interactive |
| 81 | +az feature list -o table --query "[?contains(name, 'Microsoft.ContainerService/CiliumDataplanePreview')].{Name:name,State:properties.state}" |
| 82 | +``` |
| 83 | + |
| 84 | +When the feature has been registered, refresh the registration of the *Microsoft.ContainerService* resource provider by using the `az provider register` command: |
| 85 | + |
| 86 | +```azurecli-interactive |
| 87 | +az provider register --namespace Microsoft.ContainerService |
| 88 | +``` |
| 89 | + |
| 90 | +## Create a new AKS Cluster with Azure CNI Powered by Cilium |
| 91 | + |
| 92 | +### Option 1: Assign IP addresses from a VNet |
| 93 | + |
| 94 | +Run the following commands to create a resource group and VNet with a subnet for nodes and a subnet for pods. |
| 95 | + |
| 96 | +```azurecli-interactive |
| 97 | +# Create the resource group |
| 98 | +az group create --name <resourceGroupName> --location <location> |
| 99 | +``` |
| 100 | + |
| 101 | +```azurecli-interactive |
| 102 | +# Create a VNet with a subnet for nodes and a subnet for pods |
| 103 | +az network vnet create -g <resourceGroupName> --location <location> --name <vnetName> --address-prefixes <address prefix, example: 10.0.0.0/8> -o none |
| 104 | +az network vnet subnet create -g <resourceGroupName> --vnet-name <vnetName> --name nodesubnet --address-prefixes <address prefix, example: 10.240.0.0/16> -o none |
| 105 | +az network vnet subnet create -g <resourceGroupName> --vnet-name <vnetName> --name podsubnet --address-prefixes <address prefix, example: 10.241.0.0/16> -o none |
| 106 | +``` |
| 107 | + |
| 108 | +Create the cluster using `--enable-cilium-dataplane`: |
| 109 | + |
| 110 | +```azurecli-interactive |
| 111 | +az aks create -n <clusterName> -g <resourceGroupName> -l <location> \ |
| 112 | + --max-pods 250 \ |
| 113 | + --node-count 2 \ |
| 114 | + --network-plugin azure \ |
| 115 | + --vnet-subnet-id /subscriptions/<subscriptionId>/resourceGroups/<resourceGroupName>/providers/Microsoft.Network/virtualNetworks/<vnetName>/subnets/nodesubnet \ |
| 116 | + --pod-subnet-id /subscriptions/<subscriptionId>/resourceGroups/<resourceGroupName>/providers/Microsoft.Network/virtualNetworks/<vnetName>/subnets/podsubnet \ |
| 117 | + --enable-cilium-dataplane |
| 118 | +``` |
| 119 | + |
| 120 | +### Option 2: Assign IP addresses from an overlay network |
| 121 | + |
| 122 | +Run these commands to create a resource group and VNet with a single subnet: |
| 123 | + |
| 124 | +```azurecli-interactive |
| 125 | +# Create the resource group |
| 126 | +az group create --name <resourceGroupName> --location <location> |
| 127 | +``` |
| 128 | + |
| 129 | +```azurecli-interactive |
| 130 | +# Create a VNet with a subnet for nodes and a subnet for pods |
| 131 | +az network vnet create -g <resourceGroupName> --location <location> --name <vnetName> --address-prefixes <address prefix, example: 10.0.0.0/8> -o none |
| 132 | +az network vnet subnet create -g <resourceGroupName> --vnet-name <vnetName> --name nodesubnet --address-prefixes <address prefix, example: 10.240.0.0/16> -o none |
| 133 | +``` |
| 134 | + |
| 135 | +Then create the cluster using `--enable-cilium-dataplane`: |
| 136 | + |
| 137 | +```azurecli-interactive |
| 138 | +az aks create -n <clusterName> -g <resourceGroupName> -l <location> \ |
| 139 | + --max-pods 250 \ |
| 140 | + --node-count 2 \ |
| 141 | + --network-plugin azure \ |
| 142 | + --network-plugin-mode overlay \ |
| 143 | + --pod-cidr 192.168.0.0/16 \ |
| 144 | + --vnet-subnet-id /subscriptions/<subscriptionId>/resourceGroups/<resourceGroupName>/providers/Microsoft.Network/virtualNetworks/<vnetName>/subnets/nodesubnet \ |
| 145 | + --enable-cilium-dataplane |
| 146 | +``` |
| 147 | + |
| 148 | +## Frequently asked questions |
| 149 | + |
| 150 | +- *Can I customize Cilium configuration?* |
| 151 | + |
| 152 | + No, the Cilium configuration is managed by AKS can't be modified. We recommend that customers who require more control use [AKS BYO CNI](./use-byo-cni.md) and install Cilium manually. |
| 153 | + |
| 154 | +- *Can I use `CiliumNetworkPolicy` custom resources instead of Kubernetes `NetworkPolicy` resources?* |
| 155 | + |
| 156 | + `CiliumNetworkPolicy` custom resources aren't officially supported. We recommend that customers use Kubernetes `NetworkPolicy` resources to configure network policies. |
| 157 | + |
| 158 | +## Next steps |
| 159 | + |
| 160 | +Learn more about networking in AKS in the following articles: |
| 161 | + |
| 162 | +* [Use a static IP address with the Azure Kubernetes Service (AKS) load balancer](static-ip.md) |
| 163 | +* [Use an internal load balancer with Azure Container Service (AKS)](internal-lb.md) |
| 164 | + |
| 165 | +* [Create a basic ingress controller with external network connectivity][aks-ingress-basic] |
| 166 | +* [Enable the HTTP application routing add-on][aks-http-app-routing] |
| 167 | +* [Create an ingress controller that uses an internal, private network and IP address][aks-ingress-internal] |
| 168 | +* [Create an ingress controller with a dynamic public IP and configure Let's Encrypt to automatically generate TLS certificates][aks-ingress-tls] |
| 169 | +* [Create an ingress controller with a static public IP and configure Let's Encrypt to automatically generate TLS certificates][aks-ingress-static-tls] |
| 170 | + |
| 171 | +<!-- LINKS - Internal --> |
| 172 | +[aks-ingress-basic]: ingress-basic.md |
| 173 | +[aks-ingress-tls]: ingress-tls.md |
| 174 | +[aks-ingress-static-tls]: ingress-static-ip.md |
| 175 | +[aks-http-app-routing]: http-application-routing.md |
| 176 | +[aks-ingress-internal]: ingress-internal-ip.md |
0 commit comments