Installing Prometheus Adapter
The Custom Metric API in Kubernetes is required if HPA is implemented based on custom metrics. Currently, most users use the Prometheus Adapter to provide the Custom Metric API. The Prometheus Adapter converts the received custom metric APIs to Prometheus requests and returns data queried from Prometheus to the Custom Metric API Server. The Prometheus Adapter code repository is available at https://github.com/DirectXMan12/k8s-prometheus-adapter.
Prerequisites
- The API aggregation layer has been enabled.
- The tiller has been installed in clusters.
- Helm has been installed.
Procedure
Use the Prometheus Adapter chart in the Kubernetes charts repository to install the Prometheus Adapter. For details about the chart, see https://github.com/helm/charts/tree/master/stable/prometheus-adapter.
- Check configurations in the value.yaml file.
- Information used by the Prometheus Adapter to connect to the Prometheus server includes the URL and port number. By default, the URL is http://prometheus.default.svc and the port number is 9090. Set the URL and port number based on the actual Prometheus server. If Prometheus is installed by following the procedure provided in Installing Prometheus, use the following recommended configurations: Create a value.yaml file and set installation parameters.
vi value.yaml
prometheus: url: http://prometheus-server.monitoring.svc port: 80 path: ""
- Customized rule configuration covers metric discovery rules, mapping between metrics and Kubernetes resources, exposed metric names in APIs, and corresponding Prometheus query statements. For details, see https://github.com/DirectXMan12/k8s-prometheus-adapter/blob/master/docs/config.md.
- Information used by the Prometheus Adapter to connect to the Prometheus server includes the URL and port number. By default, the URL is http://prometheus.default.svc and the port number is 9090. Set the URL and port number based on the actual Prometheus server. If Prometheus is installed by following the procedure provided in Installing Prometheus, use the following recommended configurations:
- Install Prometheus Adapter. If Helm2 is used, run the following command to install Prometheus Adapter:
helm install stable/prometheus-adapter --namespace monitoring --values value.yaml --name prometheus-adapter
If Helm3 is used, run the following command to install Prometheus Adapter:
helm install prometheus-adapter stable/prometheus-adapter --values value.yaml --namespace monitoring
After the installation is complete, run the following command to query all custom metrics:kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1"
Last Article: Installing Prometheus
Next Article: Image Repository
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.