custom metrics for horizontal pod autoscaler in OpenShift

泄露秘密 提交于 2019-12-30 07:27:10

问题


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?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/38895591/custom-metrics-for-horizontal-pod-autoscaler-in-openshift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!