Cloud Native Cluster Monitoring
Introduction
The Cloud Native Cluster Monitoring add-on (kube-prometheus-stack) uses Prometheus-operator and Prometheus to provide easy-to-use, end-to-end Kubernetes cluster monitoring.
This add-on enables monitoring data to be connected to Monitoring Center, so that you can view monitoring data and configure alarms on the console.
Open-source community: https://github.com/prometheus/prometheus
Installing the Add-on
- Log in to the CCE console, click the cluster name to go to the cluster console, choose Add-ons in the navigation pane, find the Cloud Native Cluster Monitoring add-on on the right, and click Install.
- In the Data Storage Settings area, enable Report Monitoring Data to AOM and select an AOM instance.
- Report Monitoring Data to AOM: Prometheus data will be reported to AOM. After this function is enabled, you can select the corresponding AOM instance. Basic metrics are free, but custom metrics are billed based on the standard pricing of AOM. For details, see AOM Pricing Details. To interconnect with AOM, you must have certain permissions. Only Huawei Cloud accounts, HUAWEI IDs, or users in the admin user group can perform this operation.
- Report Monitoring Data to a Third-Party Platform (configurable when Custom Metric Collection is enabled): To report Prometheus data to a third-party monitoring system, you need to enter the address and token of the third-party monitoring system and determine whether to skip certificate authentication.
- Configure the add-on specifications as needed.
- Prometheus HA: The prometheus-lightweight, prometheus-operator, custom-metrics-apiserver, and kube-state-metrics components are deployed in multiple pods in the cluster.
- Collection Shards: When there is a lot of Prometheus data, you can configure this parameter to spread the data across a specific number of Prometheus instances. This will help with storage and querying. Increasing the number of shards reduces the data volume carried by each shard. This can increase the upper limit of the metric collection throughput but cause more resources to be consumed. By default, CCE automatically determines the number of collection shards based on the cluster scale. If you want to enhance collection performance by increasing the number of shards, carefully assess resource utilization and optimize based on your monitoring needs.
- Configuration List: You can configure vCPU and memory quotas for each component as needed.
- Configure the add-on parameters as needed.
- Custom Metric Collection: If this function is enabled, metrics collected by Prometheus will be reported through the VPC endpoint of AOM. You need to create VPC endpoints for AOM beforehand. For details, see Creating an AOM Endpoint.
- Auto Service Discovery (configurable when Custom Metric Collection is enabled): If this function is enabled, application metrics can be automatically collected by annotation. By default, applications in the kube-system and monitoring namespaces are excluded from collection. For details about how to configure automatic collection of annotations, see Configuring Pod Annotations and Configuring Service Annotations.
- Collection Interval: The value ranges from 10 to 60.
- Click Install.
After installing the Cloud Native Cluster Monitoring add-on, if you need to collect custom metrics, see Monitoring Custom Metrics Using Cloud Native Cluster Monitoring in CCE Autopilot.
Components
All Kubernetes resources created during Cloud Native Cluster Monitoring add-on installation are created in the monitoring namespace.
| Component | Description | Resource Type |
|---|---|---|
| prometheusOperator (workload name: prometheus-operator) | Deploys and manages the Prometheus Server based on CustomResourceDefinitions (CRDs), and monitors and processes the events related to these CRDs. It is the control center of the entire system. | Deployment |
| prometheus-lightweight (workload name: prometheus-lightweight) | A Prometheus Server cluster deployed by the operator based on the Prometheus CRDs that can be regarded as StatefulSets. | StatefulSet |
| kubeStateMetrics (workload name: kube-state-metrics) | Converts the Prometheus metric data into a format that can be identified by Kubernetes APIs. NOTE: If the components run in multiple pods, only metrics from one of the pods are collected. | Deployment |
| adapter (workload name: custom-metrics-apiserver) | Aggregates custom metrics to the native Kubernetes API Server. This is closely related to custom metric HPA. The adapter component needs to be installed only when custom metric HPA is enabled. | Deployment |
Providing Resource Metrics Through the Metrics API
Resource metrics of containers, such as CPU and memory usage, can be obtained through the Kubernetes Metrics API. These metrics can be accessed directly by users, for example, using the kubectl top command, or consumed by HPA or CustomedHPA policies to scale workloads based on resource utilization.
The add-on can provide the Kubernetes Metrics API, which is disabled by default. To enable it, create the following APIService object:
apiVersion: apiregistration.k8s.io/v1
kind: APIService
metadata:
labels:
app: custom-metrics-apiserver
release: cceaddon-prometheus
name: v1beta1.metrics.k8s.io
spec:
group: metrics.k8s.io
groupPriorityMinimum: 100
insecureSkipTLSVerify: true
service:
name: custom-metrics-apiserver
namespace: monitoring
port: 443
version: v1beta1
versionPriority: 100 You can save the object as a file named metrics-apiservice.yaml and run the following command:
kubectl create -f metrics-apiservice.yaml
Run the kubectl top pod -n monitoring command. If output similar to the following is displayed, the Metrics API is accessible:
# kubectl top pod -n monitoring NAME CPU(cores) MEMORY(bytes) ...... custom-metrics-apiserver-d4f556ff9-l2j2m 38m 44Mi ......
To uninstall the add-on, run the following kubectl command and delete the APIService object first. Otherwise, residual APIService resources will cause the metrics-server add-on installation to fail.
kubectl delete APIService v1beta1.metrics.k8s.io
Release History
| Add-on Version | Supported Cluster Version | New Feature | Community Version |
|---|---|---|---|
| 3.12.18 |
| Supported CCE Autopilot clusters v1.36. | |
| 3.12.10 |
|
| |
| 3.12.2 |
|
| |
| 3.12.0 |
| Supported CCE Autopilot clusters v1.31. | |
| 3.9.6 |
| Upgraded the Prometheus version and removed the node-exporter component. | |
| 3.9.5 |
| Supported custom metrics. | |
| 3.9.3 |
| Fixed some issues. |
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot