custom metrics for horizontal pod autoscaler in Op

2020-03-07 03:50发布

I am using openshift v3 which uses kubernetes version 1.2. I am exploring more on autoscaling feature.
Currently it says only CPU metrics is supported.

Is there a way pods in openshift can be scaled based on memory or other metrics data collected from heapster?

2条回答
Viruses.
2楼-- · 2020-03-07 04:21

or other metrics data collected from heapster

From the announcements of Kubernetes 1.12, this should be now (Q4 2018) supported (albeit still in Beta).

Arbitrary / Custom Metrics in the Horizontal Pod Autoscaler is moving to a second beta (autoscaling/v2beta2) to test some additional feature enhancements. This reworked Horizontal Pod Autoscaler functionality includes support for custom metrics and status conditions.

See kubernetes feature 117 and commit 9d84a49, and the new Horizontal Pod Autoscaler Walkthrough page update.

It introduces the notion of labels.

Autoscaling on more specific metrics

Many metrics pipelines allow you to describe metrics either by name or by a set of additional descriptors called labels. For all non-resource metric types (pod, object, and external, described below), you can specify an additional label selector which is passed to your metric pipeline.

For instance, if you collect a metric http_requests with the verb label, you can specify the following metric block to scale only on GET requests:

type: Object
object:
  metric:
    name: `http_requests`
    selector: `verb=GET`

This selector uses the same syntax as the full Kubernetes label selectors. The monitoring pipeline determines how to collapse multiple series into a single value, if the name and selector match multiple series.

The selector is additive, and cannot select metrics that describe objects that are not the target object (the target pods in the case of the Pods type, and the described object in the case of the Object type).

custom metrics for horizontal pod autoscaler in OpenShift

查看更多
闹够了就滚
3楼-- · 2020-03-07 04:27

As you mentioned: OpenShift v3 is using multiple components of Kubernetes. The official documentation of Kubernetes and openshift are talking about autoscaling on CPU. (Kubernetes 1.2 adds alpha support for scaling based on application-specific metrics like QPS).

Autoscaling on memory wasn't released in the initial version of horizontal pod autoscaling because it does not work in the right way. Memory consumption of pods usually never shrinks, so, adding a new pod will not decrease memory consumption of the old pods.

That's why Kubernetes isn't supporting autoscaling on memory usage at the moment. They are talking about it as a possible feature:

[future] Autoscale pods based on metrics different than CPU (e.g. memory, network traffic, qps). This includes scaling based on a custom/application metric.

查看更多
登录 后发表回答