容器见解默认为托管标识身份验证,该身份验证具有一个监视代理,其使用群集的托管标识将数据发送到 Azure Monitor。 它取代了旧版基于证书的本地身份验证,并使得无需再将“监视指标发布者”角色添加到群集。
本文介绍如何在使用旧式身份验证方法启用容器见解时迁移到托管标识身份验证,以及如何启用旧式身份验证(如果需要)。
重要
如果群集采用旧式身份验证且 Log Analytics 工作区密钥轮换,则监视数据将停止流向 Log Analytics 工作区。 必须禁用容器见解加载项,然后重新启用,以便监视数据通过新的轮换工作区密钥再次开始流动。 应迁移到不使用 Log Analytics 工作区密钥的容器见解托管标识身份验证。
使用旧式身份验证查找群集
以下查询列出了在 Container Insights 中使用旧式身份验证的群集。 若要运行查询,请使用 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 群集的“监视设置”面板迁移到托管标识身份验证。 在“监视”部分中,单击“见解”选项卡。在“见解”选项卡中,单击“监视设置”选项,选中“使用托管标识”框
如果看不到“使用托管标识”选项,则你使用的是 SPN 群集。 在这种情况下,必须使用命令行工具进行迁移。 有关迁移说明和模板,请参阅其他选项卡。
启用旧式身份验证
如果需要旧式身份验证,请参阅启用容器见解,其中包含用于启用容器见解的不同选项的示例。
后续步骤
如果升级代理时遇到问题,请查看故障排除指南来获得支持。