你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
容器洞察默认使用托管标识身份验证,该身份验证具有一个监视代理,使用群集的托管标识将数据发送到 Azure Monitor。 它取代了旧版基于证书的本地身份验证,并使得无需再将“监视指标发布者”角色添加到群集。
重要
容器见解的旧式身份验证已停用。 迁移到托管身份认证。
本文介绍如何在使用旧式身份验证方法启用容器见解时迁移到托管标识身份验证,以及如何启用旧式身份验证(如果需要)。
重要
如果群集采用旧式身份验证且 Log Analytics 工作区密钥轮换,则监视数据将停止流向 Log Analytics 工作区。 必须禁用容器见解加载项,然后重新启用,以便监视数据通过新的轮换工作区密钥再次开始流动。 应迁移到不使用 Log Analytics 工作区密钥的容器见解托管标识身份验证。
使用旧式身份验证查找群集
以下查询列出了容器见解中使用旧式身份验证的群集。 若要运行查询,请使用 Resource Graph 资源管理器。 查询在现有的 Azure 门户范围内运行。 有关如何在门户中设置范围和运行 Azure Resource Graph 查询的详细信息,请参阅 快速入门:使用 Azure 门户运行 Resource Graph 查询。
查询 AKS 群集
resources
| where type =~ 'Microsoft.ContainerService/managedClusters'
| project id, name, aksproperties = parse_json(tolower(properties)), location, identity
| extend isEnabled = aksproperties.addonprofiles.omsagent.enabled
| extend workspaceResourceId = iif(isEnabled == true, aksproperties.addonprofiles.omsagent.config.loganalyticsworkspaceresourceid, '')
| extend useAADAuth = aksproperties.addonprofiles.omsagent.config.useaadauth
| where isEnabled =~ "true" and useAADAuth != true
| extend parts = split(tostring(id), "/")
| extend subscriptionId = parts[2], AKSClusterName = parts[-1], resourceGroupName = parts[4]
| project AKSClusterName, resourceGroupName, subscriptionId, location, AKSClusterId = tolower(id), workspaceResourceId
查询本地部署群集,即指使用 Arc 的群集。
KubernetesConfigurationResources
| where type =~ "Microsoft.KubernetesConfiguration/extensions"
| extend properties = parse_json(tolower(properties))
| extend extensionType = properties.extensiontype
| where extensionType in~ ('microsoft.azuremonitor.containers')
| extend omsagentUseAADAuth = tostring(properties.configurationsettings.["omsagent.useaadauth"])
| extend amalogsUseAADAuth = tostring(properties.configurationsettings.["amalogs.useaadauth"])
| extend useAADAuth = iff(omsagentUseAADAuth == 'true' or amalogsUseAADAuth == 'true', 'true', 'false')
| extend workspaceResourceId = tostring(properties.configurationsettings.loganalyticsworkspaceresourceid)
| extend resourceId = tolower(split(id, "/providers/Microsoft.KubernetesConfiguration")[0])
| where useAADAuth != "true"
| extend parts = split(tostring(resourceId), "/")
| extend subscriptionId = parts[2], ClusterName = parts[-1], ResourceGroupName = parts[4]
| project ClusterName, ResourceGroupName,resourceId, subscriptionId, workspaceResourceId
迁移到托管标识身份验证
如果在托管标识身份验证可用之前启用了容器洞察,则可以使用以下方法来迁移群集。
AKS
AKS 群集必须首先禁用监视,然后升级到托管标识。 此次迁移目前仅支持 Azure 公有云、世纪互联运营的 Microsoft Azure 和 Azure 政府云。 对于具有用户分配的标识的群集,仅支持 Azure 公有云。
注意
最低 Azure CLI 2.49.0 或更高版本。
获取配置的 Log Analytics 工作区资源 ID:
az aks show -g <resource-group-name> -n <cluster-name> | grep -i "logAnalyticsWorkspaceResourceID"使用以下命令禁用监视:
az aks disable-addons -a monitoring -g <resource-group-name> -n <cluster-name>如果群集使用的是服务主体,请使用以下命令将其升级到系统托管标识:
az aks update -g <resource-group-name> -n <cluster-name> --enable-managed-identity使用在步骤 1 中获取的 Log Analytics 工作区资源 ID 启用具有托管标识身份验证选项的监视加载项:
az aks enable-addons -a monitoring -g <resource-group-name> -n <cluster-name> --workspace-resource-id <workspace-resource-id>
启用 Arc 功能的 Kubernetes
注意
具有 ARO 的已启用 Arc 的 Kubernetes 群集不支持托管标识身份验证。
检索为容器见解扩展配置的 Log Analytics 工作区。
az k8s-extension show --name azuremonitor-containers --cluster-name \<cluster-name\> --resource-group \<resource-group\> --cluster-type connectedClusters -n azuremonitor-containers使用第一步返回的工作区,使用托管标识身份验证选项启用容器见解扩展。
az k8s-extension create --name azuremonitor-containers --cluster-name \<cluster-name\> --resource-group \<resource-group\> --cluster-type connectedClusters --extension-type Microsoft.AzureMonitor.Containers --configuration-settings amalogs.useAADAuth=true logAnalyticsWorkspaceResourceID=\<workspace-resource-id\>
启用旧式身份验证
如果需要旧式身份验证,请参阅启用容器见解,其中包含用于启用容器见解的不同选项的示例。
后续步骤
如果升级代理时遇到问题,请查看故障排除指南来获得支持。