安装

概述

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

在决定安装哪个插件之前,请先查看 Monitoring Component Selection Guide,并根据集群规模、存储方案和运维要求选择最适合的方案。

开始前准备

INFO

某些 Monitoring 组件资源消耗较高。建议通过插件配置将它们调度到 infra 节点上。Prometheus 和 VictoriaMetrics 都支持插件级别的 nodeSelectortolerations 设置。如果您正在评估产品且尚未配置 infra 节点,可以将这些设置留空,使组件运行在普通节点上。

有关 infra 节点规划的指导,请参见 Cluster Node Planning

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

  • 已参考 Monitoring Component Selection Guide 选择合适的监控组件。
  • 在业务集群中安装时,请确保 global 集群可以访问业务集群的 11780 端口。
  • 如果需要为监控数据使用 storage class 或持久卷存储,请提前在 Storage 部分创建相应资源。

ACP Monitoring with Prometheus

从控制台安装

  1. 导航到 App Store Management > Cluster Plugins,并选择目标集群。

  2. 找到 ACP Monitoring with Prometheus 插件并点击 Install

  3. 配置以下参数:

    控制台会突出显示最常用的安装选项。有关可配置字段的详细信息,请参见本节中的 YAML 参考。

    参数描述
    Scale Configuration支持三种配置:Small ScaleMedium ScaleLarge Scale
    - 默认值基于平台推荐的压测值设置
    - 可根据实际集群规模选择或自定义配额
    - 默认值会随着平台版本更新;对于固定配置,建议使用自定义设置
    Storage Type- LocalVolume:本地存储,数据存储在指定节点上
    - StorageClass:使用 storage class 自动生成持久卷
    - PV:使用现有持久卷
    注意:安装后无法修改存储配置
    Replica Count设置监控组件 pod 的数量
    注意:Prometheus 仅支持单节点安装
    Advanced Configuration可折叠区域,用于插件级调度参数。
    Node Selectors显示在 Advanced Configuration 中。为 Prometheus 插件工作负载配置插件级 node selector 规则。
    Node Tolerations显示在 Advanced Configuration 中。为 Prometheus 插件工作负载配置插件级 toleration 规则。
    Parameter Configuration可根据需要调整监控组件的数据参数
  4. 点击 Install 完成安装。

使用 YAML 安装

检查可用版本

通过检查 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

创建 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:
      nodeSelector:
        - key: kubernetes.io/os
          value: linux
      tolerations:
        - effect: NoSchedule
          key: node-role.kubernetes.io/infra
          operator: Exists
      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

资源设置示例(Prometheus):

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

有关更多详细信息,请参见 Monitor Component Capacity Planning

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存储类型:LocalVolumeStorageClassPV
spec.config.storage.capacityPrometheus 的存储大小(Gi)。建议最小 30 Gi。
spec.config.storage.nodesstorage.type=LocalVolume 时的节点列表。最多支持 1 个节点。
spec.config.storage.pathstorage.type=LocalVolume 时的基础 LocalVolume 路径。默认值:/cpaas/monitoring
spec.config.storage.storageClassstorage.type=StorageClass 时的 StorageClass 名称。
spec.config.storage.pvSelectorKstorage.type=PV 时的 PV 选择器键。
spec.config.storage.pvSelectorVstorage.type=PV 时的 PV 选择器值。
spec.config.replicas副本数;仅适用于 StorageClass/PV 类型。
spec.config.components.nodeSelector可选。为 Prometheus 插件工作负载配置插件级 node selector 规则。
spec.config.components.tolerations可选。为 Prometheus 插件工作负载配置插件级 toleration 规则。
spec.config.components.prometheus.retention数据保留天数。
spec.config.components.prometheus.scrapeInterval抓取间隔秒数;适用于未设置 interval 的 ServiceMonitors。
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监控规模:SmallMediumLarge

验证安装

由于 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:可用于安装的最新版本

将 Prometheus 工作负载放置到 Infra 节点

如果希望 Prometheus 插件工作负载运行在专用 infra 节点上,请在安装或升级期间配置插件级调度规则,而不要在安装后对生成的工作负载进行 patch。

  • 在控制台中,使用 Advanced Configuration 设置 Node SelectorsNode Tolerations
  • 在 YAML 中,设置 spec.config.components.nodeSelectorspec.config.components.tolerations

示例:

config:
  components:
    nodeSelector:
      - key: kubernetes.io/os
        value: linux
    tolerations:
      - effect: NoSchedule
        key: node-role.kubernetes.io/infra
        operator: Exists

在应用这些调度规则之前,请确保您的 infra 节点规划和存储放置是兼容的。有关规划注意事项,请参见 How To 中的 Monitoring 指南,包括 Planning Infra Nodes for Monitoring

访问已安装组件

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

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

ACP Monitoring with VictoriaMetrics

前提条件

  • 如果只安装 VictoriaMetrics agent,请确保 VictoriaMetrics Center 已安装在其他集群中。

从控制台安装

  1. 导航到 App Store Management > Cluster Plugins,并选择目标集群。

  2. 找到 ACP Monitoring with VictoriaMetrics 插件并点击 Install

  3. 配置以下参数:

    控制台会突出显示最常用的安装选项。有关可配置字段的详细信息,请参见本节中的 YAML 参考。

    参数描述
    Scale Configuration支持三种配置:Small ScaleMedium ScaleLarge Scale
    - 默认值基于平台推荐的压测值设置
    - 可根据实际集群规模选择或自定义配额
    - 默认值会随着平台版本更新;对于固定配置,建议使用自定义设置
    Install Agent Only- 关闭:安装完整的 VictoriaMetrics 组件套件
    - 开启:仅安装 VMAgent 采集组件,它依赖 VictoriaMetrics Center
    VictoriaMetrics Center选择已安装完整 VictoriaMetrics 组件的集群
    Storage Type- LocalVolume:本地存储,数据存储在指定节点上
    - StorageClass:使用 storage class 自动生成持久卷
    - PV:使用现有持久卷
    Storage PathStorage TypeLocalVolume 时显示。指定监控数据的基础存储路径。默认值:/cpaas/monitoring
    Replica CountStorage TypeStorageClassPV 时显示。设置监控组件 pod 的数量。当 Storage TypeLocalVolume 时,所选节点数量决定 VMStorage 的副本数。
    Advanced Configuration可折叠区域,用于插件级调度参数。
    Node Selectors显示在 Advanced Configuration 中。为 VictoriaMetrics 插件工作负载配置插件级 node selector 规则。
    Node Tolerations显示在 Advanced Configuration 中。为 VictoriaMetrics 插件工作负载配置插件级 toleration 规则。
    Parameter Configuration可根据需要调整监控组件的数据参数
    注意:数据在删除前可能会临时超过保留期
  4. 点击 Install 完成安装。

使用 YAML 安装

检查可用版本

通过检查 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

创建 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:
      nodeSelector:
        - key: kubernetes.io/os
          value: linux
      tolerations:
        - effect: NoSchedule
          key: node-role.kubernetes.io/infra
          operator: Exists
      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

资源设置示例(vmagent):

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

有关更多详细信息,请参见 Monitor Component Capacity Planning

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存储类型:LocalVolumeStorageClassPV
spec.config.storage.capacityVictoriaMetrics 的存储大小(Gi)。建议最小 30 Gi。
spec.config.storage.nodesstorage.type=LocalVolume 时的节点列表。可选择一个或多个节点。
spec.config.storage.pathstorage.type=LocalVolume 时的基础 LocalVolume 路径。默认值:/cpaas/monitoring
spec.config.storage.storageClassstorage.type=StorageClass 时的 StorageClass 名称。
spec.config.storage.pvSelectorKstorage.type=PV 时的 PV 选择器键。
spec.config.storage.pvSelectorVstorage.type=PV 时的 PV 选择器值。
spec.config.replicas副本数;适用于 StorageClassPV 类型。
spec.config.agentOnly是否仅安装 vmagent,而不是完整的 VictoriaMetrics 组件集合。
spec.config.agentReplicas启用仅安装 agent 模式时 vmagent 的副本数。
spec.config.crossClusterDependency.victoriametrics在启用仅安装 agent 模式时,提供 VictoriaMetrics Center 的目标集群。
spec.config.components.nodeSelector可选。为 VictoriaMetrics 插件工作负载配置插件级 node selector 规则。
spec.config.components.tolerations可选。为 VictoriaMetrics 插件工作负载配置插件级 toleration 规则。
spec.config.components.vmstorage.retentionvmstorage 的数据保留天数。
spec.config.components.vmagent.scrapeInterval抓取间隔秒数;适用于未设置 interval 的 ServiceMonitors。
spec.config.components.vmagent.scrapeTimeout抓取超时时间秒数;必须小于 scrapeInterval
spec.config.components.vmstorage.resourcesvmstorage 的资源设置。
spec.config.components.vmalert.resourcesvmalert 的资源设置。
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/custom metrics)。
spec.config.components.vmagent.resourcesvmagent 的资源设置。
spec.config.components.vminsert.resourcesvminsert 的资源设置。
spec.config.components.vmselect.resourcesvmselect 的资源设置。
spec.config.size监控规模:SmallMediumLarge

验证安装

由于 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:可用于安装的最新版本

将 VictoriaMetrics 工作负载放置到 Infra 节点

如果希望 VictoriaMetrics 插件工作负载运行在专用 infra 节点上,请在安装或升级期间配置插件级调度规则,而不要在安装后对生成的工作负载进行 patch。

  • 在控制台中,使用 Advanced Configuration 设置 Node SelectorsNode Tolerations
  • 在 YAML 中,设置 spec.config.components.nodeSelectorspec.config.components.tolerations

示例:

config:
  components:
    nodeSelector:
      - key: kubernetes.io/os
        value: linux
    tolerations:
      - effect: NoSchedule
        key: node-role.kubernetes.io/infra
        operator: Exists

在应用这些调度规则之前,请确保您的 infra 节点规划和存储放置是兼容的。有关规划注意事项,请参见 How To 中的 Monitoring 指南,包括 Planning Infra Nodes for Monitoring

访问已安装组件

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

组件访问地址
VictoriaMetrics UI<platform_access_address>/clusters/<cluster>/vmselect-ui/vmui/?#/metrics
INFO

如果启用了 Install Agent Only,则该集群不会在本地部署 vmselect 组件,因此该集群中无法使用 VictoriaMetrics UI 地址。