Skip to content

Commit 68d1c26

Browse files
committed
Update Horizontal Pod Autoscaler example documentation
1 parent e11afdf commit 68d1c26

File tree

1 file changed

+29
-11
lines changed

1 file changed

+29
-11
lines changed

examples/autoscaler/README.adoc

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -412,21 +412,32 @@ four metrics in the `custom/metrics.k8s.io` API:
412412
* `heap_memory_usage_after_gc_max`
413413

414414
The autoscaler example has a Prometheus Adapter Helm chart values file that contains the configuration for the
415-
four metrics. This can be used to install the adapter:
415+
four metrics. This can be used to install the adapter
416+
https://hub.helm.sh/charts/prometheus-com/prometheus-adapter[Helm chart]:
417+
418+
NOTE: In the command below the `--set prometheus.url=http://prometheus-prometheus-oper-prometheus.default.svc`
419+
parameter tells the adapter how to connect to Prometheus.
420+
The Prometheus Operator creates a `Service` named `prometheus-prometheus-oper-prometheus` to expose Prometheus.
421+
In this case the command assumes Prometheus is installed in the `default` namespace.
422+
If you installed Prometheus into a different namespace change the `default` part of
423+
`prometheus-prometheus-oper-prometheus.*default*.svc` to the actual namespace name.
424+
425+
NOTE: The `manifests/prometheus-adapter-values.yaml` contains the configurations for metrics that the adapter
426+
will publish. These work with Coherence Operator 3.1.0 and above. If using an earlier 3.0.x version the values
427+
file must first be edited to change all occurrences of `resource: "coherences"` to `resource: "coherence"` (to
428+
make the resource name singular).
416429

417430
[source,bash]
418431
----
419-
helm install --atomic --version 2.5.0 --wait \
432+
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
433+
helm repo update
434+
435+
helm install --atomic --wait \
420436
--set prometheus.url=http://prometheus-prometheus-oper-prometheus.default.svc \
421-
--values manifests/prometheus-adapter-values.yaml prometheus-adapter stable/prometheus-adapter
437+
--values manifests/prometheus-adapter-values.yaml \
438+
prometheus-adapter prometheus-community/prometheus-adapter
422439
----
423440

424-
NOTE: The `--set prometheus.url=http://prometheus-prometheus-oper-prometheus.default.svc` parameter tells the adapter
425-
how to connect to Prometheus.
426-
The Prometheus Operator creates a `Service` named `prometheus-prometheus-oper-prometheus` to expose Prometheus.
427-
In this case it assumes Prometheus is in the `default` namespace. If you installed Prometheus into a different
428-
namespace change the `default` part of `prometheus-prometheus-oper-prometheus.default.svc` to the actual namespace name.
429-
430441

431442
==== Query Custom Metrics
432443

@@ -487,7 +498,7 @@ NOTE: The format of the `value` field above might look a little strange. This is
487498
format, in this case it is `1300m` where the `m` stand for millis. So in this case 1300 millis is 1.3% heap usage.
488499
This is to get around the poor support in yaml and json for accurate floating-point numbers.
489500

490-
In our case for autoscaling we are interested in the maximum heap for a specific `Coherence` resource.
501+
In our case for auto-scaling we are interested in the maximum heap for a specific `Coherence` resource.
491502
Remember in the Prometheus Adapter configuration we configured the `role` metric tag to map to
492503
`coherences.coherence.oracle.com` resources.
493504
We also configured a query that will give back the maximum heap usage value for a query.
@@ -582,11 +593,18 @@ The `describedObject` section describes the resource to query, in this case kind
582593

583594
<5> The `target` section describes the target value for the metric, in this case 80 thousand millis - which is 80%.
584595

585-
<6> The `behavior` section sets a window of 120 seconds so that the HAP will wait at least 120 seconds after scaling up or down before re-evaluating the metric. This gives Coherence enough time to scale the deployment and for the data to redistribute
596+
<6> The `behavior` section sets a window of 120 seconds so that the HAP will wait at least 120 seconds after scaling up
597+
or down before re-evaluating the metric. This gives Coherence enough time to scale the deployment and for the data to redistribute
586598
and gc to occur. In real life this value would need to be adjusted to work correctly on your actual cluster.
587599

588600
The autoscaler example contains yaml to create the `HorizontalPodAutoscaler` resource in the `manifests/` directory.
589601

602+
WARNING: If using a version of Kubernetes prior to 1.18 the `behaviour` secion of the yaml above is invalid and should be
603+
removed. This could cause the HPA not to work the way we want it to as there will be no cool-down period specified
604+
between scaling operations, and the HPA could thrash or suddenly scale up or down by a lot of Pods.
605+
The only way to set these values prior to 1.18 was for the HPA as a whole
606+
(see the documentation https://v1-17.docs.kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-cooldown-delay[support for cooldown delay]).
607+
590608
[source,bash]
591609
----
592610
kubectl create -f manifests/hpa.yaml

0 commit comments

Comments
 (0)