Support to Configure HorizontalPodAutoscaler
in Rancher UI. And Support to configure HPA rules for deployment when we creating them.
APIGroup | autoscaling |
Version | v2beta2 |
Kind | HorizontalPodAutoscaler |
There are 3 versions for HorizontalPodAutoscaler.
- v1 - only support cpu average for scaling metric. Since k8s 1.1
- v2beta1 - support multiple metric type including cpu, memory and custom metrics. Only value and average value of target metric are supported. Since k8s 1.6
- v2beta2 - Including v2beta1 and support
Utilization
metric type. Since k8s 1.12
So the best api verison for the HPA object is v2beta1
HorizontalPodAutoscaler:
Name | Type | Create | Update | Null | Required | Remark |
---|---|---|---|---|---|---|
id | dnsLabel | |||||
name | string | * | * | * | (set id if null) | |
namespaceId | dnsLabel | |||||
description | string | * | * | * | annotation field | |
workloadId | dnsLabel | * | * | * | workloadId will be translated into CrossVersionObjectReference |
|
minReplicas | int | * | * | * | ||
maxReplicas | int | * | * | * | ||
metrics | array[metricSpec] | * | * | * | ||
observedGeneration | int64 | from embed status field |
||||
lastScaleTime | time | from embed status field |
||||
currentReplicas | int32 | from embed status field |
||||
desiredReplicas | int32 | from embed status field |
||||
currentMetrics | array[metricStatus] | from embed status field |
||||
conditions | array[condition] | from embed status field, ScalingActive /AbleToScale /ScalingLimited |
MetricSpec:
Name | Type | Create | Update | Null | Required | Remark |
---|---|---|---|---|---|---|
type | enum | Object ,Pods ,Resource ,External |
||||
name | dnsLabel | use for type Object , Pods and External |
||||
selector | labelSelector | use for type Object , Pods and External |
||||
describedObject | crossVersionObjectReference | use for type Object |
||||
metricType | enum | metrics quantity type, value , averageValue and averageUtilization , if value or averageValue is set, the value should be in quantity format. If averageUtilization is set, value should be in number format |
||||
value | string | value for the metric | ||||
resourceName | enum | cpu , memory , storage and ephemeral-storage only used when type is Resource |
MetricStatus:
Name | Type | Create | Update | Null | Required | Remark |
---|---|---|---|---|---|---|
type | enum | Object ,Pods ,Resource ,External |
||||
name | dnsLabel | use for type Object , Pods and External |
||||
selector | labelSelector | use for type Object , Pods and External |
||||
describedObject | crossVersionObjectReference | use for type Object |
||||
metricType | enum | metrics quantity type, value , averageValue and averageUtilization |
||||
value | quantity | current value for the metric | ||||
resourceName | enum | cpu , memory , storage and ephemeral-storage only used when type is Resource |
Name | Type | Create | Update | Null | Required | Remark |
---|---|---|---|---|---|---|
scaling | scaling | * | * | * | annotation field of deployment and replicaController |
Scaling:
One scaling object will repect to one HPA object with several metrics in it.
Name | Type | Create | Update | Null | Required | Remark |
---|---|---|---|---|---|---|
minReplicas | int | * | * | * | ||
maxReplicas | int | * | * | * | ||
metrics | array[scalingMetric] | * | * | * |
ScalingMetric:
Name | Type | Create | Update | Null | Required | Remark |
---|---|---|---|---|---|---|
name | string | only support cpu ,memory |
||||
valueType | enum | only support averageUtilization , averageValue |
||||
value | quantity | the value to trigger scaling |
For HorizontalPodAutoscaler
- Embed spec and status
- Add description for resource object
For HorizontalPodAutoscalerSpec
- Transform workloadId to
scaleTargetRef
. And onlydeployment
andreplicaController
should be allowed to be set.
For MetricSpec
- Embed
objectMetricSource
,podsMetricSource
,resourceMetricSource
andexternalMetricStatus
. Create new mapper to assign different value with different type.
For MetricStatus
- Embed
objectMetricStatus
,podsMetricStatus
,resourceMetricStatus
andexternalMetricStatus
. Create new mapper to assign different value with different type.
Adding new logic for workload.
- Add new controllers for
deployment
andreplicaController
to handle the new autoscaling field.
HorizontalPodAutoscaler
is a namespaced resource. It has the same RBAC rules as other namespaced resources.
Three aspect should be test when adding HPA object
- For the deployment and replicaController, we should test the new annotation field. Each
scaling
should create a HPA object accordingly. - For the HPA resource, It should test the API translation from Rancher API to Kubernetes object is ok or not.
- For the HPA, we should test the rules we set for scaling will work as expected.