This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.2.4. 配置监控堆栈
在 OpenShift Container Platform 4.7 中,您可以使用 cluster-monitoring-config
或 user-workload-monitoring-config
ConfigMap
配置监控堆栈。配置配置映射配置 Cluster Monitoring Operator(CMO),CMO 会配置堆栈的组件。
先决条件
如果要配置 OpenShift Container Platform 核心监控组件:
-
您可以使用具有
cluster-admin
角色的用户访问集群。 -
您已创建
cluster-monitoring-config
ConfigMap
对象。
-
您可以使用具有
如果您要配置用于监控用户定义的项目的组件:
-
您可以使用具有
cluster-admin
角色的用户访问集群,也可以使用在openshift-user-workload-monitoring
项目中具有user-workload-monitoring-config-edit
角色的用户访问集群。 -
您已创建了
user-workload-monitoring-config
ConfigMap
对象。
-
您可以使用具有
-
已安装 OpenShift CLI(
oc
)。
流程
编辑
ConfigMap
对象。要配置 OpenShift Container Platform 核心监控组件:
编辑
openshift-monitoring
项目中的cluster-monitoring-config
ConfigMap
对象:oc -n openshift-monitoring edit configmap cluster-monitoring-config
$ oc -n openshift-monitoring edit configmap cluster-monitoring-config
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 将您的配置以键值对
<component_name>: <component_configuration>
的形式添加到data/config.yaml
下:Copy to Clipboard Copied! Toggle word wrap Toggle overflow 相应地替换
<component>
和<configuration_for_the_component>
。以下示例
ConfigMap
对象为 Prometheus 配置持久性卷声明(PVC)。这与只监控 OpenShift Container Platform 核心组件的 Prometheus 实例相关:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- 定义 Prometheus 组件,后面几行则定义其配置。
要配置用于监控用户定义的项目的组件:
在
openshift-user-workload-monitoring
项目中编辑user-workload-monitoring-config
ConfigMap
对象:oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-config
$ oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-config
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 将您的配置以键值对
<component_name>: <component_configuration>
的形式添加到data/config.yaml
下:Copy to Clipboard Copied! Toggle word wrap Toggle overflow 相应地替换
<component>
和<configuration_for_the_component>
。以下示例
ConfigMap
对象为 Prometheus 配置数据保留周期和最低容器资源请求。这与仅监控用户定义的项目的 Prometheus 实例相关:Copy to Clipboard Copied! Toggle word wrap Toggle overflow 注意Prometheus 配置映射组件在
cluster-monitoring-config
ConfigMap
对象中被称为prometheusK8s
,在user-workload-monitoring-config
ConfigMap
对象中称为prometheus
。
保存文件以将更改应用到
ConfigMap
对象。受新配置影响的 Pod 会自动重启。注意除非集群管理员为用户定义的项目启用了监控,否则应用到
user-workload-monitoring-config
ConfigMap
的配置不会被激活。警告一旦将更改保存到监控配置映射,可能会重新部署相关项目中的 Pod 和其他资源。该项目中正在运行的监控进程也可能被重启。