你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
API 服务器授权 IP 范围的服务标记是一项预览功能,可用于使用服务标记为 Azure Kubernetes 服务(AKS)中的 API 服务器指定授权 IP 范围。 此功能允许你使用预定义的服务标记,而不是手动指定单个 IP 地址或 CIDR 范围,从而简化了授权 IP 范围的管理。
重要
AKS 预览功能可在自助服务和自愿选择的基础上启用。 预览版按“现状”和“视供应情况”提供,它们不包括在服务级别协议和有限保证范围内。 AKS 预览功能是由客户支持尽最大努力部分覆盖。 因此,这些功能并不适合用于生产。 有关详细信息,请参阅以下支持文章:
先决条件
- 已安装并配置 Azure CLI 2.0.76 或更高版本。 使用
az --version命令查看版本。 如果需要安装或升级,请参阅 安装 Azure CLI。 - 已安装
aks-previewAzure CLI 扩展。 - 在你的 Azure 订阅中注册的
EnableServiceTagAuthorizedIPPreview功能标志。
局限性
- 此功能与 API Server VNet 集成不兼容。
-
--api-server-authorized-ip-ranges参数中只允许一个服务标记。 不能指定多个服务标记。
安装 aks-preview Azure CLI 扩展
使用
az extension add命令安装 Azure CLI 预览扩展。az extension add --name aks-preview使用
az extension update命令更新,确保拥有最新版本的扩展。az extension update --name aks-preview
注册服务标记授权 IP 功能标志
使用
EnableServiceTagAuthorizedIPPreview命令注册az feature register功能标志。 只需几分钟时间即可完成注册。az feature register --namespace "Microsoft.ContainerService" --name "EnableServiceTagAuthorizedIPPreview"示例输出:
{ "id": "/subscriptions/<subscription-id>/providers/Microsoft.ContainerService/features/EnableServiceTagAuthorizedIPPreview", "name": "EnableServiceTagAuthorizedIPPreview", "properties": { "state": "Registering" }, "type": "Microsoft.ContainerService/features" }当功能标志状态从
Registering更改为Registered时,使用az provider register命令刷新Microsoft.ContainerService资源提供程序的注册。az provider register --namespace "Microsoft.ContainerService"使用
az feature show命令验证注册。az feature show --namespace "Microsoft.ContainerService" --name "EnableServiceTagAuthorizedIPPreview"示例输出:
{ "id": "/subscriptions/<subscription-id>/providers/Microsoft.ContainerService/features/EnableServiceTagAuthorizedIPPreview", "name": "EnableServiceTagAuthorizedIPPreview", "properties": { "state": "Registered" }, "type": "Microsoft.ContainerService/features" }
创建具有服务标记授权 IP 范围的 AKS 群集
使用
az aks create命令和--api-server-authorized-ip-ranges参数创建具有服务标记授权 IP 范围的群集。 以下示例在 myResourceGroup 资源组中创建名为 myAKSCluster 的群集,并授权AzureCloud服务标记允许所有 Azure 服务访问 API 服务器并指定额外的 IP 地址:az aks create --resource-group myResourceGroup --name myAKSCluster --api-server-authorized-ip-ranges AzureCloud,20.20.20.20注释
你应该能够从属于
AzureCloud服务标记的 Azure 虚拟机 (VM) 或 Azure 服务中通过 curl 访问 API 服务器。