Post

VPA(Vertical Pod Autoscaler) in kubernets

https://github.com/kubernetes/autoscaler/tree/master/vertical-pod-autoscaler

针对项目中服务的自动垂直伸缩(对应的还有一个HPA Horizontal Pod Autoscaler)

Vertical Pod Autoscaler (VPA) frees users from the necessity of setting up-to-date resource limits and requests for the containers in their pods. When configured, it will set the requests automatically based on usage and thus allow proper scheduling onto nodes so that appropriate resource amount is available for each pod. It will also maintain ratios between limits and requests that were specified in initial containers configuration.

It can both down-scale pods that are over-requesting resources, and also up-scale pods that are under-requesting resources based on their usage over time.

Autoscaling is configured with a Custom Resource Definition object called VerticalPodAutoscaler. It allows to specify which pods should be vertically autoscaled as well as if/how the resource recommendations are applied.

使用VPA的几个步骤:

  1. 安装VPA
  2. 创建一个VerticalPodAutoscaler类型的CRD文件
  3. 使用kubectl describe vpa 查看建议值

支持四种策略,建议设置为Off,只给出参考,不实际对pod进行操作。

“Auto”: VPA assigns resource requests on pod creation as well as updates them on existing pods using the preferred update mechanism. Currently, this is equivalent to “Recreate” (see below). Once restart free (“in-place”) update of pod requests is available, it may be used as the preferred update mechanism by the “Auto” mode. “Recreate”: VPA assigns resource requests on pod creation as well as updates them on existing pods by evicting them when the requested resources differ significantly from the new recommendation (respecting the Pod Disruption Budget, if defined). This mode should be used rarely, only if you need to ensure that the pods are restarted whenever the resource request changes. Otherwise, prefer the “Auto” mode which may take advantage of restart-free updates once they are available. “Initial”: VPA only assigns resource requests on pod creation and never changes them later. “Off”: VPA does not automatically change the resource requirements of the pods. The recommendations are calculated and can be inspected in the VPA object.

This post is licensed under CC BY 4.0 by the author.