安装

概述

监控组件为可观测性模块中的监控、告警、检查和健康检查功能提供基础设施。本文档介绍如何在集群中安装带 Prometheus 插件的 ACP Monitoring 或带 VictoriaMetrics 插件的 ACP Monitoring。

NOTE

从 ACP 4.5 开始,以下插件已重命名:

  • ACP Monitoring for Prometheus 更名为 ACP Basic Monitoring。
  • ACP Monitoring for VictoriaMetrics 更名为 ACP Advanced Monitoring。

从 Customer Portal 下载插件时,请搜索新名称。重命名前发布的插件包在上传后,平台中仍会显示原名称。

安装准备

INFO

Monitoring 的某些组件会占用大量资源。建议在基础设施节点上运行这些组件,并设置 nodeSelector 和容忍度,以确保它们仅在这些节点上运行。如果您正在评估产品且尚未配置基础设施节点,可以移除这些设置,使组件在所有节点上运行。

有关规划基础设施节点的指导,请参阅集群节点规划。

安装监控组件前,请确保满足以下条件:

  • 参阅监控组件选择指南并选择适当的监控组件。
  • 在业务集群中安装时,请确保 global 集群可以访问业务集群的 11780 端口。
  • 如果需要使用存储类或持久卷存储监控数据,请提前在存储部分创建相应资源。
  • 在安装前确定用于存储监控数据的集群。global 集群会安装自身的完整组件集,并且仅监控自身。在多集群平台上,请将聚合业务集群指标的 VictoriaMetrics Center 安装在专用业务集群中,而不是 global 集群中;然后将每个业务集群安装为仅智能体模式,并指向该集群,以确保管理集群的可用性和应用监控负载相互独立。
  • 如果 global 集群配置了灾难恢复,则业务集群监控不得指向主集群或备用 global 集群。灾难恢复仅同步 global 集群的 etcd 数据,不包括 cpaas-system 等命名空间,因此监控数据不会被复制,并且在故障转移后将不可用。每个 global 集群仅监控自身。有关同步范围,请参阅全局集群灾难恢复。

通过 console 安装带 Prometheus Plugin 的 ACP Monitoring

安装步骤

  1. 导航至应用商店管理 > 集群插件,然后选择目标集群。

  2. 找到 ACP Basic Monitoring 插件(对于重命名前发布的软件包,显示为 ACP Monitoring for Prometheus),然后点击安装。

  3. 配置以下参数:

    参数描述
    规模配置支持三种配置:小规模、中规模和大规模:
    - 默认值根据平台推荐的负载测试值设置
    - 您可以根据实际集群规模选择或自定义配额
    - 默认值将随平台版本更新;对于固定配置,建议使用自定义设置
    存储类型- LocalVolume:本地存储,数据存储在指定节点上
    - StorageClass:使用存储类自动生成持久卷
    - PV:使用现有持久卷
    注意:安装后无法修改存储配置
    从节点数量设置监控组件 Pod 的数量
    注意:Prometheus 仅支持单节点安装
    参数配置可根据需要调整监控组件的数据参数
  4. 点击安装以完成安装。

访问方式

安装完成后,可以通过以下地址访问组件(将 <> 替换为实际值):

组件访问地址
Thanos<platform_access_address>/clusters/<cluster>/prometheus
Prometheus<platform_access_address>/clusters/<cluster>/prometheus-0
Alertmanager<platform_access_address>/clusters/<cluster>/alertmanager

通过 YAML 安装带有 Prometheus 插件的 ACP Monitoring

1. 检查可用版本

在 global集群中检查 ModulePlugin 和 ModuleConfig 资源,确保插件已发布:


# kubectl get moduleplugin | grep prometheus
prometheus                       30h
# kubectl get moduleconfig | grep prometheus
prometheus-v4.1.0                30h

这表示集群中存在 ModulePlugin prometheus,且已发布版本 v4.1.0。

2. 创建 ModuleInfo

创建 ModuleInfo 资源以安装插件,无需配置任何参数:

kind: ModuleInfo
apiVersion: cluster.alauda.io/v1alpha1
metadata:
  name: global-prometheus
  labels:
    cpaas.io/cluster-name: global
    cpaas.io/module-name: prometheus
    cpaas.io/module-type: plugin
spec:
  version: v4.1.0
  config:
    storage:
      type: LocalVolume
      capacity: 40
      nodes:
        - xxx.xxx.xxx.xx
      path: /cpaas/monitoring
      storageClass: ""
      pvSelectorK: ""
      pvSelectorV: ""
    replicas: 1
    components:
      prometheus:
        retention: 7
        scrapeInterval: 60
        scrapeTimeout: 45
        resources: null
      nodeExporter:
        port: 9100
        resources: null
      alertmanager:
        resources: null
      kubeStateExporter:
        resources: null
      prometheusAdapter:
        resources: null
      thanosQuery:
        resources: null
    size: Small
  valuesOverride:
    ait/chart-kube-prometheus:
      global:
        nodeSelector:
          node-role.kubernetes.io/infra: "true"
        tolerations:
        - effect: NoSchedule
          key: node-role.kubernetes.io/infra
          value: reserved
          operator: Equal

资源设置参考示例(prometheus):

spec:
  config:
    components:
      prometheus:
        resources:
          limits:
            cpu: 2000m
            memory: 2000Mi
          requests:
            cpu: 1000m
            memory: 1000Mi

更多详情,请参阅监控组件容量规划

YAML 字段参考(Prometheus):

字段路径描述
metadata.labels.cpaas.io/cluster-name安装插件的目标集群名称。
metadata.labels.cpaas.io/module-name必须为 prometheus。
metadata.labels.cpaas.io/module-type必须为 plugin。
metadata.nameModuleInfo 名称(例如 <cluster>-prometheus)。
spec.version要安装的插件版本。
spec.config.storage.type存储类型:LocalVolume、StorageClass 或 PV。
spec.config.storage.capacityPrometheus 的存储大小(Gi)。建议至少为 30 Gi。
spec.config.storage.nodes当 storage.type=LocalVolume 时使用的节点列表。最多支持 1 个节点。
spec.config.storage.path当 storage.type=LocalVolume 时使用的 LocalVolume 路径。
spec.config.storage.storageClass当 storage.type=StorageClass 时使用的 StorageClass 名称。
spec.config.storage.pvSelectorK当 storage.type=PV 时使用的 PV 选择器键。
spec.config.storage.pvSelectorV当 storage.type=PV 时使用的 PV 选择器值。
spec.replicas从节点数量;仅适用于 StorageClass/PV 类型。
spec.config.components.prometheus.retention数据保留天数。
spec.config.components.prometheus.scrapeInterval抓取间隔(秒);适用于未设置 interval 的 ServiceMonitor。
spec.config.components.prometheus.scrapeTimeout抓取超时时间(秒);必须小于 scrapeInterval。
spec.config.components.prometheus.resourcesPrometheus 的资源设置。
spec.config.components.nodeExporter.portNode Exporter 端口(默认值为 9100)。
spec.config.components.nodeExporter.resourcesNode Exporter 的资源设置。
spec.config.components.alertmanager.resourcesAlertmanager 的资源设置。
spec.config.components.kubeStateExporter.resourcesKube State Exporter 的资源设置。
spec.config.components.prometheusAdapter.resourcesPrometheus Adapter 的资源设置。
spec.config.components.thanosQuery.resourcesThanos Query 的资源设置。
spec.config.size监控规模:Small、Medium 或 Large。
spec.valuesOverride.ait/chart-kube-prometheus.global.nodeSelector可选。Monitoring 组件的节点选择器。使用此参数为 Monitoring 组件选择节点。此参数主要用于基础设施节点。
spec.valuesOverride.ait/chart-kube-prometheus.global.tolerations可选。Monitoring 组件的容忍度。如果节点选择器选中了带污点的节点,请使用此参数指定可容忍的污点键、值和效果。此参数主要用于基础设施节点。

3. 验证安装

由于创建后 ModuleInfo 名称会发生变化,请通过标签查找资源,以检查插件状态和版本:

kubectl get moduleinfo -l cpaas.io/module-name=prometheus
NAME                                             CLUSTER         MODULE        DISPLAY_NAME   STATUS    TARGET_VERSION   CURRENT_VERSION   NEW_VERSION
global-e671599464a5b1717732c5ba36079795          global          prometheus    prometheus     Running   v4.1.0           v4.1.0            v4.1.0

字段说明:

  • NAME:ModuleInfo 资源名称
  • CLUSTER:安装插件的集群
  • MODULE:插件名称
  • DISPLAY_NAME:插件显示名称
  • STATUS:安装状态;Running 表示已成功安装并正在运行
  • TARGET_VERSION:计划安装的版本
  • CURRENT_VERSION:安装前的版本
  • NEW_VERSION:可供安装的最新版本

通过控制台安装带有 VictoriaMetrics Plugin 的 ACP Monitoring

前提条件

  • 如果只安装 VictoriaMetrics agent,请确保已在另一个集群中安装 VictoriaMetrics Center。

安装步骤

  1. 前往 应用商店管理 > 集群插件,并选择目标集群。

  2. 找到 ACP Advanced Monitoring 插件(重命名前发布的版本显示为 ACP Monitoring for VictoriaMetrics),然后点击 安装。

  3. 配置以下参数:

    参数描述
    规模配置支持三种配置:小规模、中规模和大规模:
    - 默认值根据平台推荐的负载测试值设置
    - 可根据实际集群规模选择或自定义配额
    - 默认值会随平台版本更新;如需固定配置,建议使用自定义设置
    仅安装智能体- 关闭:安装完整的 VictoriaMetrics 组件套件
    - 开启:仅安装 VMAgent 采集组件,该组件依赖 VictoriaMetrics Center
    VictoriaMetrics Center选择已安装完整 VictoriaMetrics 组件的集群
    存储类型- LocalVolume:本地存储,数据存储在指定节点上
    - StorageClass:使用存储类自动创建持久卷
    - PV:使用现有持久卷
    副本数设置监控组件 Pod 的数量:
    - LocalVolume 存储类型不支持多个副本
    - 对于其他存储类型,请参阅屏幕提示进行配置
    参数配置可调整监控组件的数据参数
    注意:数据在删除前可能会暂时超过保留期限
  4. 点击 安装 完成安装。

通过 YAML 安装带 VictoriaMetrics Plugin 的 ACP Monitoring

1. 检查可用版本

在 global集群中检查 ModulePlugin 和 ModuleConfig 资源,确保插件已发布:


# kubectl get moduleplugin | grep victoriametrics
victoriametrics                       30h
# kubectl get moduleconfig | grep victoriametrics
victoriametrics-v4.1.0                30h

这表示集群中存在 ModulePlugin victoriametrics,并且已发布版本 v4.1.0。

2. 创建 ModuleInfo

创建 ModuleInfo 资源,在不配置任何参数的情况下安装插件:

kind: ModuleInfo
apiVersion: cluster.alauda.io/v1alpha1
metadata:
  name: business-1-victoriametrics
  labels:
    cpaas.io/cluster-name: business-1
    cpaas.io/module-name: victoriametrics
    cpaas.io/module-type: plugin
spec:
  version: v4.1.0
  config:
    storage:
      type: LocalVolume
      capacity: 40
      nodes:
        - xxx.xxx.xxx.xx
      path: /cpaas/monitoring
      storageClass: ""
      pvSelectorK: ""
      pvSelectorV: ""
    replicas: 1
    agentOnly: false
    agentReplicas: 1
    crossClusterDependency:
      victoriametrics: ""
    components:
      nodeExporter:
        port: 9100
        resources: null
      vmstorage:
        retention: 7
        resources: null
      kubeStateExporter:
        resources: null
      vmalert:
        resources: null
      prometheusAdapter:
        resources: null
      vmagent:
        scrapeInterval: 60
        scrapeTimeout: 45
        resources: null
      vminsert:
        resources: null
      alertmanager:
        resources: null
      vmselect:
        resources: null
    size: Small
  valuesOverride:
    ait/chart-victoriametrics:
      global:
        nodeSelector:
          node-role.kubernetes.io/infra: "true"
        tolerations:
        - effect: NoSchedule
          key: node-role.kubernetes.io/infra
          value: reserved
          operator: Equal

资源配置参考(示例为 prometheus):

spec:
  config:
    components:
      vmagent:
        resources:
          limits:
            cpu: 2000m
            memory: 2000Mi
          requests:
            cpu: 1000m
            memory: 1000Mi

如需了解更多详情,请参阅监控组件容量规划

YAML 字段参考(VictoriaMetrics):

字段路径描述
metadata.labels.cpaas.io/cluster-name安装插件的目标集群名称。
metadata.labels.cpaas.io/module-name必须为 victoriametrics。
metadata.labels.cpaas.io/module-type必须为 plugin。
metadata.nameModuleInfo 名称(例如 <cluster>-victoriametrics)。
spec.version要安装的插件版本。
spec.config.storage.type存储类型:LocalVolume、StorageClass 或 PV。
spec.config.storage.capacityVictoriaMetrics 的存储大小(Gi)。建议最小为 30 Gi。
spec.config.storage.nodes使用 storage.type=LocalVolume 时的节点列表。最多支持 1 个节点。
spec.config.storage.path使用 storage.type=LocalVolume 时的 LocalVolume 路径。
spec.config.storage.storageClass使用 storage.type=StorageClass 时的 StorageClass 名称。
spec.config.storage.pvSelectorK使用 storage.type=PV 时的 PV 选择器键。
spec.config.storage.pvSelectorV使用 storage.type=PV 时的 PV 选择器值。
spec.replicas副本数;LV 不支持多个副本。
spec.config.components.vmstorage.retentionvmstorage 的数据保留天数。
spec.config.components.vmagent.scrapeInterval抓取间隔(秒);适用于未设置 interval 的 ServiceMonitor。
spec.config.components.vmagent.scrapeTimeout抓取超时时间(秒);必须小于 scrapeInterval。
spec.config.components.vmstorage.resourcesvmstorage 的资源配置。
spec.config.components.nodeExporter.portNode Exporter 端口(默认值为 9100)。
spec.config.components.nodeExporter.resourcesNode Exporter 的资源配置。
spec.config.components.alertmanager.resourcesAlertmanager 的资源配置。
spec.config.components.kubeStateExporter.resourcesKube State Exporter 的资源配置。
spec.config.components.prometheusAdapter.resourcesPrometheus Adapter 的资源配置(用于 HPA/自定义指标)。
spec.config.components.vmagent.resourcesvmagent 的资源配置。
spec.config.size监控规模:Small、Medium 或 Large。
spec.valuesOverride.ait/chart-victoriametrics.global.nodeSelector可选。监控组件的节点选择器。使用此参数为监控组件选择节点。此参数主要用于基础设施节点。
spec.valuesOverride.ait/chart-victoriametrics.global.tolerations可选。监控组件的容忍度。如果节点选择器选择了带污点的节点,请使用此参数指定污点容忍度的键、值和效果。此参数主要用于基础设施节点。

3. 验证安装

由于 ModuleInfo 名称会在创建后发生变化,请通过标签查找资源,以检查插件状态和版本:

kubectl get moduleinfo -l cpaas.io/module-name=victoriametrics
NAME                                             CLUSTER         MODULE            DISPLAY_NAME     STATUS    TARGET_VERSION   CURRENT_VERSION   NEW_VERSION
global-e671599464a5b1717732c5ba36079795          global          victoriametrics   victoriametrics  Running   v4.1.0           v4.1.0            v4.1.0

字段说明:

  • NAME:ModuleInfo 资源名称
  • CLUSTER:安装插件的集群
  • MODULE:插件名称
  • DISPLAY_NAME:插件的显示名称
  • STATUS:安装状态;Running 表示已成功安装并运行
  • TARGET_VERSION:计划安装的版本
  • CURRENT_VERSION:安装前的版本
  • NEW_VERSION:可安装的最新版本