安装

概述

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

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

Perses 监控仪表盘需要额外的 dashboard 组件。当你需要在 Operations Center > Monitor > Dashboards (Perses) 中查看、创建或迁移 dashboard 时,请安装这些组件。

开始之前

INFO

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

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

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

  • 已通过 监控组件选型指南 选择了合适的监控组件。
  • 在 workload cluster 中安装时,确保 global 集群可以访问 workload cluster 的 11780 端口。
  • 如果需要为监控数据使用 storage classes 或 persistent volume 存储,请提前在 Storage 部分创建相应资源。

安装 Perses Dashboard 组件

Perses 监控 dashboard 依赖以下组件:

ComponentInstallation locationPurpose
Alauda Container Platform Dashboard Essentialsglobal 集群为 Perses dashboards 提供支持 RBAC 的指标查询服务。
Alauda Container Platform Dashboard for Persesglobal 集群运行唯一的 Perses server 实例。workload cluster 按需安装 operator 以提供 PersesDashboard CRD,但不会创建 Perses 实例。提供 Perses dashboard 后端、渲染、编辑以及 PersesDashboard 资源管理能力。

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

请按以下顺序安装这些组件:

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

  2. global 集群中创建一个 ObserveAPI 实例。你可以使用组件的 Create 操作或 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 实例。你可以使用组件的 Create 操作或 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 dashboards 的 workload cluster,安装 Alauda Container Platform Dashboard for Perses,以便在该集群中提供 PersesDashboard CRD。不要在 workload cluster 中创建 Perses 实例。

  6. 转到 Operations Center > Monitor > Dashboards (Perses),并验证所选集群中是否可以看到 dashboard 列表。

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

Perses dashboard 组件复用现有的平台指标存储,例如 VictoriaMetrics 或 Prometheus。它们不会引入独立的指标存储或 tenant。

安装 operator 仅会安装 controller 和 CRD。你必须先在 global 集群中创建相应的 ObserveAPIPerses 实例,然后才会启动实际的 observe-api 和 Perses server 工作负载。

ACP Monitoring with Prometheus

从控制台安装

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

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

  3. 配置以下参数:

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

    ParameterDescription
    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

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

YAML 字段参考(Prometheus):

Field pathDescription
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

访问已安装组件

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

ComponentAccess Address
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 参考。

    ParameterDescription
    Scale Configuration支持三种配置:Small ScaleMedium ScaleLarge Scale
    - 默认值基于平台推荐的压测值设置
    - 你可以根据实际集群规模选择或自定义配额
    - 默认值会随平台版本更新;对于固定配置,建议使用自定义设置
    Install Agent Only- Off:安装完整的 VictoriaMetrics 组件套件
    - On:仅安装 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

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

YAML 字段参考(VictoriaMetrics):

Field pathDescription
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

访问已安装组件

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

ComponentAccess Address
VictoriaMetrics UI<platform_access_address>/clusters/<cluster>/vmselect-ui/vmui/?#/metrics
INFO

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