安装

概述

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

要确定安装哪个插件,请先查阅 监控组件选型指南,并选择最符合您集群规模、存储方案和运维需求的选项。

Perses 监控面板需要额外的监控面板组件。当您需要在 运维中心 > 监控 > 监控面板 (Perses) 中查看、创建或迁移监控面板时,请安装这些组件。

开始之前

INFO

部分监控组件较为消耗资源。建议通过插件配置将它们放置到 infra 节点上。Prometheus 和 VictoriaMetrics 均支持插件级别的 nodeSelector 和 tolerations 设置。如果您正在评估产品且尚未规划 infra 节点,可以将这些设置留空,使组件运行在普通节点上。

有关规划 infra 节点的指导,请参见 集群节点规划。

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

  • 已参考 监控组件选型指南 选择合适的监控组件。
  • 在业务集群中安装时,请确保 global 集群可以访问该业务集群的 11780 端口。
  • 如果需要使用存储类或持久卷存储监控数据,请提前在 存储 部分创建相应资源。
  • 安装前请确定由哪个集群存储监控数据。global 集群会安装自身的完整组件集,并且仅监控自身。在多集群平台上,请将用于聚合业务集群指标的 VictoriaMetrics Center 安装在专用业务集群中,而不是安装在 global 集群中,并将每个业务集群以仅 Agent 模式安装并指向该集群,从而使管理集群可用性与应用监控负载保持独立。
  • 如果 global 集群部署了容灾,业务集群的监控不得指向主或备 global 集群。容灾仅同步 global 集群的 etcd 数据,并排除 cpaas-system 等命名空间,因此监控数据不会被复制,故障切换后将不可用。每个 global 集群仅监控自身。有关同步范围,请参见 Global 集群容灾。
  • 如果集群使用 Immutable Infrastructure,并且计划使用 LocalVolume 存储,请不要保留默认存储路径。请参见 Immutable Infrastructure 上的 LocalVolume 存储路径。

Immutable Infrastructure 上的 LocalVolume 存储路径

两个监控插件都将 LocalVolume 存储路径默认设置为 /cpaas/monitoring,该路径属于传统操作系统布局。在使用 Immutable Infrastructure 的集群中,节点运行 Alauda OS,根文件系统为只读,节点本地的平台数据保存在 /var/cpaas 下,该路径位于供应商机器配置中声明的持久磁盘上。写入这些已声明磁盘之外的任何内容,在平台替换节点时都不会被保留。其他平台组件已遵循此约定;例如,在 Immutable OS 集群上,etcd 备份使用 /var/cpaas/backup。请参见 etcd 备份与恢复。

在此类集群上使用 LocalVolume 存储安装任一监控插件时:

  • 将存储路径设置为 /var/cpaas/monitoring,而不是默认的 /cpaas/monitoring。在控制台中设置 存储路径;在 YAML 中设置 spec.config.storage.path。

  • 在 spec.config.storage.nodes 中列出的每个节点上,为该路径配备一块持久磁盘,容量需满足您所配置的存储大小。平台会在这些节点上于该路径下创建数据目录,因此该路径必须可写。请在管理该集群的供应商的持久磁盘字段中声明该磁盘,以便在节点替换后仍然保留:

    供应商持久磁盘字段
    Huawei DCSDCSIpHostnamePool.spec.pool[].persistentDisk
    VMware vSphereVSphereMachineConfigPool.spec.configs[].persistentDisks[]
    Huawei Cloud StackHCSMachineConfigPool.spec.configs[].persistentDisks[]
    裸金属MachineInventory.spec.storage.volumes[]

    有关各供应商的声明操作步骤,请参见 创建集群。在裸金属上,磁盘已挂载到物理主机,并在长期存在的 MachineInventory 上声明,而不是从 IaaS 平台申请,因此请按照 管理裸金属主机上的数据磁盘 操作,并在 inventory 仍未分配时声明该卷。

  • 请勿让监控数据无规划地与平台 /var/cpaas 磁盘共用。监控数据会随所配置的规模和保留期限增长,因此请为 /var/cpaas/monitoring 配备专用磁盘,或将现有 /var/cpaas 磁盘的容量规划为同时覆盖监控所需容量。

请在安装插件时设置该路径。对于 ACP Monitoring with Prometheus,存储配置在安装后无法修改。

安装 Perses 监控面板组件

Perses 监控面板依赖于以下组件:

组件安装位置用途
Alauda Container Platform Dashboard Essentials仅 global 集群提供 Perses 监控面板所使用的、具备 RBAC 感知能力的指标查询服务。
Alauda Container Platform Dashboard for Persesglobal 集群运行唯一的 Perses server 实例。业务集群按需安装 operator 以提供 PersesDashboard CRD,但不创建 Perses 实例。提供 Perses 监控面板的后端、渲染、编辑以及 PersesDashboard 资源管理能力。

Perses server 和 observe-api 仅在 global 集群中创建。当您在控制台中选择业务集群时,控制台仍会将 Perses server 请求路由到 global 集群。所选业务集群决定使用哪个集群的指标和 PersesDashboard 资源。observe-api 跨集群查询指标并执行 RBAC。

请按以下顺序安装组件:

  1. 在 global 集群中安装 Alauda Container Platform Dashboard Essentials。

  2. 在 global 集群中创建 ObserveAPI 实例。您可以使用该组件或 OperatorHub 入口的 创建 操作,或应用如下 CR:

    apiVersion: observe.alauda.io/v1alpha1
    kind: ObserveAPI
    metadata:
      name: observe-api
      namespace: cpaas-system
    spec: {}

    确认 observe-api Deployment 处于运行状态。

  3. 在 global 集群中安装 Alauda Container Platform Dashboard for Perses。

  4. 在 global 集群中创建唯一的 Perses 实例。您可以使用该组件或 OperatorHub 入口的 创建 操作,或应用如下 CR:

    apiVersion: perses.dev/v1alpha2
    kind: Perses
    metadata:
      name: cpaas-perses
      namespace: cpaas-system
      annotations:
        perses.dev/ingress.enabled: "true"
    spec:
      replicas: 2
      containerPort: 8080
      storage:
        emptyDir: {}
      config:
        frontend:
          disable: true

    确认 cpaas-perses Deployment 处于运行状态。

  5. 对于用户需要查看或创建 Perses 监控面板的每个业务集群,安装 Alauda Container Platform Dashboard for Perses,以便在该集群中提供 PersesDashboard CRD。请勿在业务集群中创建 Perses 实例。

  6. 前往 运维中心 > 监控 > 监控面板 (Perses),确认所选集群中的监控面板列表可用。

如果所选集群尚未安装 Alauda Container Platform Dashboard for Perses,Perses 监控面板页面将显示安装指南,而不是监控面板列表。

Perses 监控面板组件复用现有的平台指标存储,例如 VictoriaMetrics 或 Prometheus。它们不会引入单独的指标存储或租户。

仅安装 operator 只会安装控制器和 CRD。您必须在 global 集群中创建相应的 ObserveAPI 和 Perses 实例,实际的 observe-api 和 Perses server 工作负载才会启动。

ACP Monitoring with Prometheus

从控制台安装

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

  2. 找到 ACP Monitoring with Prometheus 插件,然后单击 安装。

  3. 配置以下参数:

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

    参数说明
    规模配置支持三种配置:小规模、中规模 和 大规模:
    - 默认值基于平台推荐的负载测试值设置
    - 您可以根据实际集群规模选择或自定义配额
    - 默认值会随平台版本更新;如需固定配置,建议使用自定义设置
    存储类型- LocalVolume:本地存储,数据存储在指定节点上
    - StorageClass:使用存储类自动生成持久卷
    - PV:使用现有持久卷
    注意:存储配置在安装后无法修改
    存储路径当 存储类型 为 LocalVolume 时显示。用于存储 Prometheus 数据的主机目录;必须为绝对路径。默认值:/cpaas/monitoring。在 Immutable Infrastructure 上,请设置为 /var/cpaas/monitoring;请参见 Immutable Infrastructure 上的 LocalVolume 存储路径。
    副本数设置监控组件 Pod 的数量
    注意:Prometheus 仅支持单节点安装
    高级配置用于插件级调度参数的可折叠部分。
    节点选择器在 高级配置 中显示。为 Prometheus 插件工作负载配置插件级节点选择器规则。
    节点容忍在 高级配置 中显示。为 Prometheus 插件工作负载配置插件级容忍规则。
    参数配置可根据需要调整监控组件的数据参数
  4. 单击 安装 以完成安装。

使用 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 # On Immutable Infrastructure use /var/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

有关更多详细信息,请参见 监控组件容量规划。

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 基础路径。默认值:/cpaas/monitoring。在 Immutable Infrastructure 上,请设置为 /var/cpaas/monitoring;请参见 Immutable Infrastructure 上的 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.config.replicas副本数;仅适用于 StorageClass/PV 类型。
spec.config.components.nodeSelector可选。Prometheus 插件工作负载的插件级节点选择器规则。
spec.config.components.tolerations可选。Prometheus 插件工作负载的插件级容忍规则。
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。

验证安装

由于 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 节点上,请在安装或升级期间配置插件级调度规则,而不是在安装后对已生成的工作负载进行修补。

  • 在控制台中,使用 高级配置 设置 节点选择器 和 节点容忍。
  • 在 YAML 中,设置 spec.config.components.nodeSelector 和 spec.config.components.tolerations。

示例:

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

在应用这些调度规则之前,请确保您的 infra 节点规划与存储放置相互兼容。有关规划注意事项,请参见 操作指南 中的监控指南,包括 为监控规划 Infra 节点。

访问已安装的组件

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

组件访问地址
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. 导航至 应用商店管理 > 集群插件,并选择目标集群。

  2. 找到 ACP Monitoring with VictoriaMetrics 插件,然后单击 安装。

  3. 配置以下参数:

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

    参数说明
    规模配置支持三种配置:小规模、中规模 和 大规模:
    - 默认值基于平台推荐的负载测试值设置
    - 您可以根据实际集群规模选择或自定义配额
    - 默认值会随平台版本更新;如需固定配置,建议使用自定义设置
    仅安装 Agent- 关闭:安装完整的 VictoriaMetrics 组件套件
    - 开启:仅安装 VMAgent 采集组件,该组件依赖于 VictoriaMetrics Center
    VictoriaMetrics Center选择已安装完整 VictoriaMetrics 组件的集群
    存储类型- LocalVolume:本地存储,数据存储在指定节点上
    - StorageClass:使用存储类自动生成持久卷
    - PV:使用现有持久卷
    存储路径当 存储类型 为 LocalVolume 时显示。指定监控数据的基础存储路径。默认值:/cpaas/monitoring。在 Immutable Infrastructure 上,请设置为 /var/cpaas/monitoring;请参见 Immutable Infrastructure 上的 LocalVolume 存储路径。
    副本数当 存储类型 为 StorageClass 或 PV 时显示。设置监控组件 Pod 的数量。当 存储类型 为 LocalVolume 时,所选节点的数量决定 VMStorage 的副本数。
    高级配置用于插件级调度参数的可折叠部分。
    节点选择器在 高级配置 中显示。为 VictoriaMetrics 插件工作负载配置插件级节点选择器规则。
    节点容忍在 高级配置 中显示。为 VictoriaMetrics 插件工作负载配置插件级容忍规则。
    参数配置可以调整监控组件的数据参数
    注意:数据在被删除前可能会暂时超出保留期限
  4. 单击 安装 以完成安装。

使用 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 # On Immutable Infrastructure use /var/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

有关更多详细信息,请参见 监控组件容量规划。

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 时的节点列表。可以选择一个或多个节点。
spec.config.storage.path当 storage.type=LocalVolume 时的 LocalVolume 基础路径。默认值:/cpaas/monitoring。在 Immutable Infrastructure 上,请设置为 /var/cpaas/monitoring;请参见 Immutable Infrastructure 上的 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.config.replicas副本数;适用于 StorageClass 和 PV 类型。
spec.config.agentOnly是否仅安装 vmagent,而不安装完整的 VictoriaMetrics 组件集。
spec.config.agentReplicas启用仅 Agent 模式时 vmagent 的副本数。
spec.config.crossClusterDependency.victoriametrics启用仅 Agent 模式时,提供 VictoriaMetrics Center 的目标集群。
spec.config.components.nodeSelector可选。VictoriaMetrics 插件工作负载的插件级节点选择器规则。
spec.config.components.tolerations可选。VictoriaMetrics 插件工作负载的插件级容忍规则。
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.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/自定义指标)。
spec.config.components.vmagent.resourcesvmagent 的资源配置。
spec.config.components.vminsert.resourcesvminsert 的资源配置。
spec.config.components.vmselect.resourcesvmselect 的资源配置。
spec.config.size监控规模:Small、Medium 或 Large。

验证安装

由于 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 节点上,请在安装或升级期间配置插件级调度规则,而不是在安装后对已生成的工作负载进行修补。

  • 在控制台中,使用 高级配置 设置 节点选择器 和 节点容忍。
  • 在 YAML 中,设置 spec.config.components.nodeSelector 和 spec.config.components.tolerations。

示例:

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

在应用这些调度规则之前,请确保您的 infra 节点规划与存储放置相互兼容。有关规划注意事项,请参见 操作指南 中的监控指南,包括 为监控规划 Infra 节点。

访问已安装的组件

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

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

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