你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

使用高级容器网络服务启用 eBPF 主机路由(预览版)

重要

具有高级容器网络服务的 eBPF 主机路由目前为预览版。
有关适用于 Beta 版、预览版或尚未正式发布的 Azure 功能的法律条款,请参阅 适用于 Microsoft azure 预览版的补充使用条款

本文介绍如何在 Azure Kubernetes 服务(AKS)群集上启用高级容器网络服务(ACNS)的 eBPF 主机路由。

先决条件

  • 拥有有效订阅的 Azure 帐户。 如果没有帐户,请在开始之前创建 一个免费帐户
  • 本文中的步骤所需的最低 Azure CLI 版本为 2.71.0。 若要查找版本,请运行 az --version。 如果需要安装或升级,请参阅 安装 Azure CLI

  • eBPF 主机路由仅受由 Cilium 提供支持的 Azure CNI 支持。 有关托管 Cilium 群集的详细信息,请参阅 配置由 Cilium 提供支持的 Azure CNI

  • 查看“ 限制” 部分,了解节点要求和与现有 iptable 规则的兼容性。

安装 aks-preview Azure CLI 扩展

重要

AKS 预览功能可在自助服务和自愿选择的基础上启用。 预览版按“现状”和“视供应情况”提供,它们不包括在服务级别协议和有限保证范围内。 AKS 预览功能是由客户支持尽最大努力部分覆盖。 因此,这些功能并不适合用于生产。 有关详细信息,请参阅以下支持文章:

使用 az extension addaz extension update 命令安装或更新 Azure CLI 预览扩展。

aks-preview Azure CLI 扩展的最低版本为 14.0.0b6

# Install the aks-preview extension
az extension add --name aks-preview
# Update the extension to make sure you have the latest version installed
az extension update --name aks-preview

注册 AdvancedNetworkingPerformancePreview 功能标志

使用 AdvancedNetworkingPerformancePreview 命令注册 az feature register 功能标志。

az feature register --namespace "Microsoft.ContainerService" --name "AdvancedNetworkingPerformancePreview"

使用 az feature show 命令验证注册是否成功。 只需几分钟时间即可完成注册。

az feature show --namespace "Microsoft.ContainerService" --name "AdvancedNetworkingPerformancePreview"

在功能显示Registered后,使用Microsoft.ContainerService命令刷新az provider register资源提供程序的注册。

启用高级容器网络服务和 eBPF 主机路由

若要继续,必须有一个启用了高级容器网络服务的 AKS 群集。

具有高级容器网络服务标志 az aks create--enable-acns 命令创建一个新的 AKS 群集,它具有所有高级容器网络服务功能。 这些功能包括:

  • 容器网络可观测性:提供对您的网络流量的深入见解。 若要了解详细信息,请访问容器网络可观测性

  • 容器网络安全:提供 FQDN 筛选等安全功能。 若要了解详细信息,请访问容器网络安全

  • 容器网络性能: 提高 Pod 网络流量的延迟和吞吐量。 若要了解详细信息,请访问 容器网络性能

注释

Cilium 数据面的群集支持容器网络性能,并且从 Kubernetes 版本 1.33 开始支持 eBPF 主机路由。

警告

只有具有 Ubuntu 24.04 或 Azure Linux 3.0 的节点兼容。 如果使用 Ubuntu 24.04,请参阅 预览文档 以启用功能标志。

使用 az group create 命令为群集创建 Azure 资源组。

export LOCATION="<location>"

az group create --location $LOCATION --name <resourcegroup-name>

通过启用 ACNS --enable-acns 并通过 --acns-datapath-acceleration-mode BpfVeth 设置加速模式,使用 eBPF 主机路由创建新的 AKS 群集。

# Set environment variables for the AKS cluster name and resource group. Make sure to replace the placeholders with your own values.
export CLUSTER_NAME="<aks-cluster-name>"
export RESOURCE_GROUP="<resourcegroup-name>"
export LOCATION="<location>"
export OS_SKU="<os-sku>" # Use AzureLinux or Ubuntu2404
 
# Create an AKS cluster
az aks create \
    --name $CLUSTER_NAME \
    --resource-group $RESOURCE_GROUP \
    --location $LOCATION \
    --network-plugin azure \
    --network-plugin-mode overlay \
    --network-dataplane cilium \
    --kubernetes-version 1.33 \
    --os-sku $OS_SKU \
    --enable-acns \
    --acns-datapath-acceleration-mode BpfVeth \
    --generate-ssh-keys

在现有群集上使用高级容器网络服务启用 eBPF 主机路由

具有高级容器网络服务标志 az aks update--enable-acns 命令通过 --acns-datapath-acceleration-mode BpfVeth 更新现有的 AKS 群集,以启用高级容器网络服务功能,其中包括容器网络可观测性容器网络安全容器网络性能

注释

在现有群集上启用 eBPF 主机路由可能会中断现有连接。

az aks update \
    --resource-group $RESOURCE_GROUP \
    --name $CLUSTER_NAME \
    --enable-acns \
    --acns-datapath-acceleration-mode BpfVeth

在现有群集上禁用 eBPF 主机路由

可以独立禁用 eBPF 主机路由,而不会影响其他 ACNS 功能。 若要禁用它,请设置标志 --acns-datapath-acceleration-mode=None

az aks update \
    --resource-group $RESOURCE_GROUP \
    --name $CLUSTER_NAME \
    --enable-acns \
    --acns-datapath-acceleration-mode None