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.Este contenido no está disponible en el idioma seleccionado.
Chapter 8. Exposing custom application metrics for autoscaling
You can export custom application metrics for the horizontal pod autoscaler.
Prometheus Adapter is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.
For more information about the support scope of Red Hat Technology Preview features, see https://access.redhat.com/support/offerings/techpreview/.
8.1. Exposing custom application metrics for horizontal pod autoscaling Copiar enlaceEnlace copiado en el portapapeles!
You can use the prometheus-adapter
resource to expose custom application metrics for the horizontal pod autoscaler.
Prerequisites
-
You have a custom Prometheus instance installed as a Prometheus pod managed by a deployment or
StatefulSet
object but not by a Prometheus custom resource (CR). You have installed the custom Prometheus instance in a user-defined
custom-prometheus
project.ImportantCustom Prometheus instances and the Prometheus Operator installed through Operator Lifecycle Manager (OLM) are not compatible with user-defined monitoring if it is enabled. Therefore, custom Prometheus instances that are installed as a Prometheus custom resource (CR) managed by the OLM Prometheus Operator are not supported in OpenShift Container Platform.
-
You have deployed an application and a service in a user-defined project. In this example, it is presumed that the application and its service monitor were installed in a user-defined
custom-prometheus
project. -
You have installed the OpenShift CLI (
oc
).
Procedure
-
Create a YAML file for your configuration. In this example, the file is called
deploy.yaml
. Add configuration details for creating the service account, roles, and role bindings for
prometheus-adapter
:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add configuration details for the custom metrics for
prometheus-adapter
:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add configuration details for registering
prometheus-adapter
as an API service:Copy to Clipboard Copied! Toggle word wrap Toggle overflow List the Prometheus Adapter image:
oc get -n openshift-monitoring deploy/prometheus-adapter -o jsonpath="{..image}"
$ oc get -n openshift-monitoring deploy/prometheus-adapter -o jsonpath="{..image}"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add configuration details for deploying
prometheus-adapter
:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Specifies the Prometheus Adapter image found in the previous step.
Apply the configuration to the cluster:
oc apply -f deploy.yaml
$ oc apply -f deploy.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the
prometheus-adapter
pod in your user-defined project is in aRunning
state. In this example the project iscustom-prometheus
:oc -n custom-prometheus get pods prometheus-adapter-<string>
$ oc -n custom-prometheus get pods prometheus-adapter-<string>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - The metrics for the application are now exposed and they can be used to configure horizontal pod autoscaling.