Skip to content

Commit 058ece3

Browse files
authored
add support for hpa behavior configuration. (#167)
1 parent 2b05cf4 commit 058ece3

File tree

2 files changed

+68
-5
lines changed

2 files changed

+68
-5
lines changed

charts/k8s-service/templates/horizontalpodautoscaler.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,8 @@ spec:
2828
type: Utilization
2929
averageUtilization: {{ .Values.horizontalPodAutoscaler.avgMemoryUtilization }}
3030
{{- end }}
31+
{{- if .Values.horizontalPodAutoscaler.behavior }}
32+
behavior:
33+
{{ tpl (toYaml .Values.horizontalPodAutoscaler.behavior) $ | indent 4 }}
34+
{{- end }}
3135
{{- end }}

charts/k8s-service/values.yaml

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -705,12 +705,71 @@ serviceAccount:
705705

706706
# horizontalPodAutoscaler is a map that configures the Horizontal Pod Autoscaler information for this pod
707707
# The expected keys of hpa are:
708-
# - enabled (bool) : Whether or not Horizontal Pod Autoscaler should be created, if false the
708+
# - enabled (bool) : Whether or not Horizontal Pod Autoscaler should be created, if false the
709709
# Horizontal Pod Autoscaler will not be created
710-
# - minReplicas (int) : The minimum amount of replicas allowed
711-
# - maxReplicas (int) : The maximum amount of replicas allowed
712-
# - avgCpuUtilization (int) : The target average CPU utilization to be used with the metrics
713-
# - avgMemoryUtilization (int) : The target average Memory utilization to be used with the metrics
710+
# - minReplicas (int) : The minimum amount of replicas allowed
711+
# - maxReplicas (int) : The maximum amount of replicas allowed
712+
# - avgCpuUtilization (int) : The target average CPU utilization to be used with the metrics
713+
# - avgMemoryUtilization (int) : The target average Memory utilization to be used with the metrics
714+
# - behavior (object) : Configures the scaling behavior of the target in both Up and Down directions
715+
# (scaleUp and scaleDown fields respectively). If not set, the default
716+
# HPAScalingRules for scale up and scale down are used.
717+
# Details: https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/horizontal-pod-autoscaler-v2/#HorizontalPodAutoscalerSpec
718+
# The expected attributes of the "behavior" object are:
719+
# - scaleDown (object) : The scaling policy for scaling Down
720+
# - scaleUp (object) : The scaling policy for scaling Up
721+
#
722+
# The expected attributes of both the "scaleDown" and "scaleUp" objects are:
723+
# - policies (list[object]) : List of potential scaling policies which can be used during
724+
# scaling. At least one policy must be specified, otherwise the
725+
# HPAScalingRules will be discarded as invalid
726+
# - selectPolicy (string) : Used to specify which policy should be used. If not set, the
727+
# default value MaxPolicySelect is used.
728+
# - stabilizationWindowSeconds (int) : The number of seconds for which past recommendations should be
729+
# considered while scaling up or scaling down. StabilizationWindowSeconds
730+
# must be greater than or equal to zero and less than or equal to 3600 (one hour).
731+
# If not set, use the default values:
732+
# - For scale up: 0 (i.e. no stabilization is done).
733+
# - For scale down: 300 (i.e. the stabilization window is 300 seconds long).
734+
#
735+
# The expected attributes of the "policies" list for both the "scaleDown" and "scaleUp" objects are:
736+
# - periodSeconds (int) : Specifies the window of time for which the policy should hold true. PeriodSeconds
737+
# must be greater than zero and less than or equal to 1800 (30 min).
738+
# - type (string) : Used to specify the scaling policy.
739+
# - value (int) : The amount of change which is permitted by the policy. It must be greater than zero.
740+
#
741+
# Example horizontalPodAutoscaler with "behavior" configuration:
742+
#
743+
# apiVersion: autoscaling/v2
744+
# kind: HorizontalPodAutoscaler
745+
# metadata:
746+
# name: k8s-service-canary-test
747+
# namespace: default
748+
# spec:
749+
# scaleTargetRef:
750+
# apiVersion: apps/v1
751+
# kind: Deployment
752+
# name: k8s-service-canary-test
753+
# minReplicas: 1
754+
# maxReplicas: 10
755+
# behavior:
756+
# scaleDown:
757+
# policies:
758+
# - periodSeconds: 15
759+
# type: Percent
760+
# value: 100
761+
# stabilizationWindowSeconds: 300
762+
# scaleUp:
763+
# policies:
764+
# - periodSeconds: 15
765+
# type: Percent
766+
# value: 100
767+
# - periodSeconds: 15
768+
# type: Pods
769+
# value: 4
770+
# selectPolicy: Max
771+
# stabilizationWindowSeconds: 0
772+
#
714773
#
715774
# The default config will not create the Horizontal Pod Autoscaler by setting enabled = false, the default values are
716775
# set so if enabled is true the horizontalPodAutoscaler has valid values.

0 commit comments

Comments
 (0)