停用 Kubernetes 叢集的監視
使用下列方法,從 Kubernetes 叢集移除 Container insights 或 Prometheus 。
所需的權限
- 您至少 需要叢集的參與者 存取權。
停用容器深入解析
AKS cluster
使用 az aks disable-addons CLI 命令來停用叢集上的容器深入解析。 命令會從叢集節點移除代理程式。 它不會移除叢集的Log Analytics工作區中已收集並儲存的數據。
az aks disable-addons -a monitoring -n MyExistingManagedCluster -g MyExistingManagedClusterRG
或者,您可以使用下列 ARM 範本來移除容器深入解析。
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"aksResourceId": {
"type": "string",
"metadata": {
"description": "AKS Cluster Resource ID"
}
},
"aksResourceLocation": {
"type": "string",
"metadata": {
"description": "Location of the AKS resource e.g. \"East US\""
}
},
"aksResourceTagValues": {
"type": "object",
"metadata": {
"description": "Existing all tags on AKS Cluster Resource"
}
}
},
"resources": [
{
"name": "[split(parameters('aksResourceId'),'/')[8]]",
"type": "Microsoft.ContainerService/managedClusters",
"location": "[parameters('aksResourceLocation')]",
"tags": "[parameters('aksResourceTagValues')]",
"apiVersion": "2018-03-31",
"properties": {
"mode": "Incremental",
"id": "[parameters('aksResourceId')]",
"addonProfiles": {
"omsagent": {
"enabled": false,
"config": null
}
}
}
}
]
}
已啟用 Arc 的 Kubernetes 叢集
下列 PowerShell 和 Bash 腳本可用於從已啟用 Arc 的 Kubernetes 叢集移除容器深入解析。 您可以執行 命令 kubectl config get-contexts
來取得叢集的 kube 內容。 如果您想要使用目前的內容,請勿指定此參數。
PowerShell: disable-monitoring.ps1
# Use current context
.\disable-monitoring.ps1 -clusterResourceId <cluster-resource-id>
# Specify kube-context
.\disable-monitoring.ps1 -clusterResourceId <cluster-resource-id> -kubeContext <kube-context>
Bash: disable-monitoring.sh
# Use current context
bash disable-monitoring.sh --resource-id $AZUREARCCLUSTERRESOURCEID
# Specify kube-context
bash disable-monitoring.sh --resource-id $AZUREARCCLUSTERRESOURCEID --kube-context $KUBECONTEXT
使用 Helm 移除容器深入解析
下列步驟適用於下列環境:
- Azure 和 Azure Stack 上的 AKS 引擎
- OpenShift 第 4 版和更新版本
執行下列 helm 命令來識別叢集上安裝的容器深入解析 helm 圖表版本
helm list
輸出類似下列:
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION azmon-containers-release-1 default 3 2020-04-21 15:27:24.1201959 -0700 PDT deployed azuremonitor-containers-2.7.0 7.0.0-1
azmon-containers-release-1 代表「容器深入解析」的 Helm 圖表版本。
如果要刪除圖表版本,請執行下列 Helm 命令。
helm delete <releaseName>
範例:
helm delete azmon-containers-release-1
這將會從叢集移除發行版本。 您可以執行
helm list
命令來驗證:NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
可能需要幾分鐘的時間才能完成設定變更。 即使您將版本刪除,Helm 也會加以追蹤,所以您可以稽核叢集歷程記錄,甚至使用 helm rollback
將版本取消刪除。
停用 Prometheus
使用下列 az aks update
Azure CLI 命令搭配 --disable-azure-monitor-metrics
參數,從 AKS 叢集或 Azure CLI 命令中移除計量附加元件,並使用 --name azuremonitor-metrics
參數從已啟用 Arc 的叢集az k8s-extension delete
移除計量附加元件,並停止將 Prometheus 計量傳送至適用於 Prometheus 的 Azure 監視器受控服務。 它不會移除叢集的 Azure 監視器工作區中已收集的數據並儲存。
AKS 叢集:
az aks update --disable-azure-monitor-metrics -n <cluster-name> -g <cluster-resource-group>
已啟用 Azure Arc 的叢集:
az k8s-extension delete --name azuremonitor-metrics --cluster-name <cluster-name> --resource-group <cluster-resource-group> --cluster-type connectedClusters
這個指令會執行下列動作:
- 從叢集節點移除 ama-metrics 代理程式。
- 刪除為該叢集建立的記錄規則。
- 刪除資料收集端點 (DCE)。
- 刪除資料收集規則 (DCR)。
- 刪除資料收集規則關聯 (DCRA) 和記錄在上架時建立的規則群組。
下一步
如果工作區只為了支援監視叢集而建立,而且不再需要它,您必須手動刪除它。 如果您不熟悉如何刪除工作區,請參閱使用 Azure 入口網站 刪除 Azure Log Analytics 工作區。 別忘了步驟 4 稍早複製的 工作區資源標識符 。 您將需要該資訊。