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.Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 2. 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/.
2.1. Exposing custom application metrics for horizontal pod autoscaling Copier lienLien copié sur presse-papiers!
You can use the prometheus-adapter
resource to expose custom application metrics for the horizontal pod autoscaler.
Prerequisites
-
Make sure you have a custom Prometheus instance installed. In this example, it is presumed that Prometheus was installed in the
default
namespace. -
Make sure you configured monitoring for your application. In this example, it is presumed that the application and the service monitor for it were installed in the
default
namespace.
Procedure
-
Create a YAML file for your configuration. In this example, it is called
deploy.yaml
. Add configuration for creating the service account, necessary roles, and role bindings for
prometheus-adapter
:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add configuration for the custom metrics for
prometheus-adapter
:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add configuration for registering
prometheus-adapter
as an API service:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Show the Prometheus Adapter image to use:
kubectl get -n openshift-monitoring deploy/prometheus-adapter -o jsonpath="{..image}"
$ kubectl get -n openshift-monitoring deploy/prometheus-adapter -o jsonpath="{..image}" quay.io/openshift-release-dev/ocp-v4.2-art-dev@sha256:76db3c86554ad7f581ba33844d6a6ebc891236f7db64f2d290c3135ba81c264c
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add configuration for deploying
prometheus-adapter
:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
image: openshift-release-dev/ocp-v4.2-art-dev
specifies the Prometheus Adapter image found in the previous step.
Apply the configuration file to the cluster:
oc apply -f deploy.yaml
$ oc apply -f deploy.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Now the application’s metrics are exposed and can be used to configure horizontal pod autoscaling.
Additional resources