必须使用 az extension remove --name aks-preview 命令从 AKS 群集中卸载 aks-preview 扩展。
必须使用 az extension add --name k8s-extension 命令安装 k8s-extension 扩展。
需要 k8s-extension 版本 1.4.1 或更高版本。
AKS 群集
使用 -enable-azure-monitor-metrics 选项 az aks create 或 az aks update(具体取决于是要创建新群集还是要更新现有群集)来安装用于擦除 Prometheus 指标的指标加载项。
示例命令
### Use default Azure Monitor workspace
az aks create/update --enable-azure-monitor-metrics --name <cluster-name> --resource-group <cluster-resource-group>
### Use existing Azure Monitor workspace
az aks create/update --enable-azure-monitor-metrics --name <cluster-name> --resource-group <cluster-resource-group> --azure-monitor-workspace-resource-id <workspace-name-resource-id>
### Use an existing Azure Monitor workspace and link with an existing Grafana workspace
az aks create/update --enable-azure-monitor-metrics --name <cluster-name> --resource-group <cluster-resource-group> --azure-monitor-workspace-resource-id <azure-monitor-workspace-name-resource-id> --grafana-resource-id <grafana-workspace-name-resource-id>
### Use optional parameters
az aks create/update --enable-azure-monitor-metrics --name <cluster-name> --resource-group <cluster-resource-group> --ksm-metric-labels-allow-list "namespaces=[k8s-label-1,k8s-label-n]" --ksm-metric-annotations-allow-list "pods=[k8s-annotation-1,k8s-annotation-n]"
已启用 Arc 的群集(预览版)
### Use default Azure Monitor workspace
az k8s-extension create --name azuremonitor-metrics --cluster-name <cluster-name> --resource-group <resource-group> --cluster-type connectedClusters --extension-type Microsoft.AzureMonitor.Containers.Metrics
## Use existing Azure Monitor workspace
az k8s-extension create --name azuremonitor-metrics --cluster-name <cluster-name> --resource-group <resource-group> --cluster-type connectedClusters --extension-type Microsoft.AzureMonitor.Containers.Metrics --configuration-settings azure-monitor-workspace-resource-id=<workspace-name-resource-id>
### Use an existing Azure Monitor workspace and link with an existing Grafana workspace
az k8s-extension create --name azuremonitor-metrics --cluster-name <cluster-name> --resource-group <resource-group> --cluster-type connectedClusters --extension-type Microsoft.AzureMonitor.Containers.Metrics --configuration-settings azure-monitor-workspace-resource-id=<workspace-name-resource-id> grafana-resource-id=<grafana-workspace-name-resource-id>
### Use optional parameters
az k8s-extension create --name azuremonitor-metrics --cluster-name <cluster-name> --resource-group <resource-group> --cluster-type connectedClusters --extension-type Microsoft.AzureMonitor.Containers.Metrics --configuration-settings azure-monitor-workspace-resource-id=<workspace-name-resource-id> grafana-resource-id=<grafana-workspace-name-resource-id> AzureMonitorMetrics.KubeStateMetrics.MetricAnnotationsAllowList="pods=[k8s-annotation-1,k8s-annotation-n]" AzureMonitorMetrics.KubeStateMetrics.MetricLabelsAllowlist "namespaces=[k8s-label-1,k8s-label-n]"
windows-exporter-daemonset.yaml 中不存在 CPU/内存限制,因此可能会过度预配 Windows 节点
有关更多详细信息,请参阅资源预留
在部署工作负载时,请对容器设置资源内存和 CPU 限制。 这也会从 NodeAllocatable 中减去,并帮助群集范围的计划程序确定在哪些节点上放置哪些 Pod。
无限制地计划 Pod 可能会过度预配 Windows 节点,并且在极端情况下可能会导致节点运行不正常。
自版本为 6.4.0-main-02-22-2023-3ee44b9e 的托管 Prometheus 加载项容器 (prometheus_collector) 起,为 AKS 群集启用 Windows 指标收集。 加入 Azure Monitor 指标加载项将使 Windows DaemonSet Pod 开始在节点池上运行。 支持 Windows Server 2019 和 Windows Server 2022。 按照以下步骤使 Pod 能够从 Windows 节点池收集指标。
kubectl get ds ama-metrics-node --namespace=kube-system
Pod 数应等于群集上的 Linux 节点数。 输出应与下面的示例类似:
User@aksuser:~$ kubectl get ds ama-metrics-node --namespace=kube-system
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
ama-metrics-node 1 1 1 1 1 <none> 10h
验证是否已正确部署 Windows 节点
kubectl get ds ama-metrics-win-node --namespace=kube-system
Pod 数应等于群集上的 Windows 节点数。 输出应与下面的示例类似:
User@aksuser:~$ kubectl get ds ama-metrics-node --namespace=kube-system
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
ama-metrics-win-node 3 3 3 3 3 <none> 10h
验证是否为 Prometheus 部署了两个 ReplicaSet
kubectl get rs --namespace=kube-system
输出应与下面的示例类似:
User@aksuser:~$kubectl get rs --namespace=kube-system
NAME DESIRED CURRENT READY AGE
ama-metrics-5c974985b8 1 1 1 11h
ama-metrics-ksm-5fcf8dffcd 1 1 1 11h
容器见解
验证是否已在 Linux 节点池上正确部署 DaemonSet
kubectl get ds ama-logs --namespace=kube-system
Pod 数应等于群集上的 Linux 节点数。 输出应与下面的示例类似:
User@aksuser:~$ kubectl get ds ama-logs --namespace=kube-system
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
ama-logs 2 2 2 2 2 <none> 1d
验证是否已正确部署 Windows 节点
kubectl get ds ama-logs-windows --namespace=kube-system
Pod 数应等于群集上的 Windows 节点数。 输出应与下面的示例类似:
User@aksuser:~$ kubectl get ds ama-logs-windows --namespace=kube-system
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
ama-logs-windows 2 2 2 2 2 <none> 1d
验证容器见解解决方案的部署
kubectl get deployment ama-logs-rs --namespace=kube-system
输出应与下面的示例类似:
User@aksuser:~$ kubectl get deployment ama-logs-rs --namespace=kube-system
NAME READY UP-TO-DATE AVAILABLE AGE
ama-logs-rs 1/1 1 1 24d
使用 CLI 查看配置
使用 aks show 命令查看是否已启用解决方案,并查看 Log Analytics 工作区资源 ID 以及有关群集的摘要信息。
az aks show --resource-group <resourceGroupofAKSCluster> --name <nameofAksCluster>
Windows 没有内存 RSS 指标。 因此它不适用于 Windows 节点和容器。 可使用工作集指标。
磁盘存储容量信息不适用于 Windows 节点。
仅监视 Pod 环境,不监视 Docker 环境。
使用预览版时,最多支持 30 个 Windows Server 容器。 此限制不适用于 Linux 容器。
备注
容器见解对 Windows Server 2022 操作系统的支持目前为公共预览版。
容器化 Linux 代理 (replicaset pod) 向群集内 Kubelet 安全端口 (10250) 上的所有 Windows 节点进行 API 调用,以收集与节点和容器性能相关的指标。 应在群集的虚拟网络中针对入站和出站打开 Kubelet 安全端口 (:10250),以便正常收集 Windows 节点和容器性能相关指标。
如果你有一个包含 Windows 节点的 Kubernetes 群集,请查看并配置网络安全组和网络策略,确保在群集的虚拟网络中针对入站和出站打开 Kubelet 安全端口 (:10250)。