9.2. 从联邦端点收集集群指标
您可以使用 OpenShift Container Platform 集群的联邦端点,为 OpenShift (RHOSO) 集群上的 Red Hat OpenStack Services (RHOSO) 集群提供指标来练习基于拉取的监控。
先决条件
- 您有对 RHOSO 的管理访问权限,以及其上运行的租户集群。
- Telemetry 在 RHOSO 环境中被启用。
- Cluster Observability Operator 已安装在集群中。
- 配置了集群的监控堆栈。
- 您的集群已公开联邦端点。
流程
-
使用用户名和密码连接到集群 ; 不要使用安装程序生成的
kubeconfig文件登录。 要从 OpenShift Container Platform 集群检索令牌,请在上面运行以下命令:
$ oc whoami -t运行以下命令,使令牌作为 secret 在 RHOSO 管理集群中的
openstack命名空间中作为 secret 可用:$ oc -n openstack create secret generic ocp-federated --from-literal=token=<the_token_fetched_previously>要从 OpenShift Container Platform 集群获取 Prometheus 联邦路由 URL,请运行以下命令:
$ oc -n openshift-monitoring get route prometheus-k8s-federate -ojsonpath={'.status.ingress[].host'}为提取配置编写清单,并将它保存为名为
cluster-scrape-config.yaml的文件。例如:apiVersion: monitoring.rhobs/v1alpha1 kind: ScrapeConfig metadata: labels: service: metricStorage name: sos1-federated namespace: openstack spec: params: 'match[]': - '{__name__=~"kube_node_info|kube_persistentvolume_info|cluster:master_nodes"}'1 metricsPath: '/federate' authorization: type: Bearer credentials: name: ocp-federated2 key: token scheme: HTTPS # or HTTP scrapeInterval: 30s3 staticConfigs: - targets: - prometheus-k8s-federate-openshift-monitoring.apps.openshift.example4 连接到 RHOSO 管理集群时,运行以下命令应用清单:
$ oc apply -f cluster-scrape-config.yaml
配置传播后,集群指标可以访问在 RHOSO 中的 OpenShift Container Platform UI 中查询。