Skip to content

Commit 099b7ce

Browse files
authored
Add Support for Custom Metrics (#196)
* add support for hpa custom scaling metrics * update CI builder image to internal ci image * update pre-commit setup to align with ci builder image * update minikube version in ci * revert minikube upgrade * revert test specific minikube upgrade
1 parent 8a50e60 commit 099b7ce

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

.circleci/config.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ base_env: &base_env
77
GRUNTWORK_INSTALLER_VERSION: v0.0.38
88
TERRATEST_LOG_PARSER_VERSION: v0.40.6
99
HELM_VERSION: v3.8.0
10-
MODULE_CI_VERSION: v0.51.0
10+
MODULE_CI_VERSION: v0.55.1
1111
MINIKUBE_VERSION: v1.28.0
1212
TERRAFORM_VERSION: NONE
1313
TERRAGRUNT_VERSION: NONE
@@ -76,25 +76,18 @@ jobs:
7676
environment:
7777
<<: *base_env
7878
docker:
79-
- image: cimg/python:3.10.2
79+
- image: 087285199408.dkr.ecr.us-east-1.amazonaws.com/circle-ci-test-image-base:go1.21.9-tf1.5-tg39.1-pck1.8-ci54.0
8080
steps:
8181
- checkout
8282
# Install gruntwork utilities
8383
- run:
8484
<<: *install_gruntwork_utils
85-
# Export go install location to $PATH so it is available in subsequent steps
86-
- run:
87-
command: |
88-
echo 'export PATH=/usr/local/go/bin:$PATH' >> $BASH_ENV
8985
- run:
9086
<<: *install_helm_client
9187
# Fail the build if the pre-commit hooks don't pass. Note: if you run pre-commit install locally, these hooks will
9288
# execute automatically every time before you commit, ensuring the build never fails at this step!
9389
- run:
9490
command: |
95-
pip install pre-commit
96-
# Go's location was added to the PATH above
97-
go get golang.org/x/tools/cmd/goimports
9891
pre-commit install
9992
pre-commit run --all-files
10093
- persist_to_workspace:

charts/k8s-service/templates/horizontalpodautoscaler.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,25 @@ spec:
1212
minReplicas: {{ .Values.horizontalPodAutoscaler.minReplicas }}
1313
maxReplicas: {{ .Values.horizontalPodAutoscaler.maxReplicas }}
1414
metrics:
15-
{{ if .Values.horizontalPodAutoscaler.avgCpuUtilization }}
15+
{{- if .Values.horizontalPodAutoscaler.avgCpuUtilization }}
1616
- type: Resource
1717
resource:
1818
name: cpu
1919
target:
2020
type: Utilization
2121
averageUtilization: {{ .Values.horizontalPodAutoscaler.avgCpuUtilization }}
2222
{{- end }}
23-
{{ if .Values.horizontalPodAutoscaler.avgMemoryUtilization }}
23+
{{- if .Values.horizontalPodAutoscaler.avgMemoryUtilization }}
2424
- type: Resource
2525
resource:
2626
name: memory
2727
target:
2828
type: Utilization
2929
averageUtilization: {{ .Values.horizontalPodAutoscaler.avgMemoryUtilization }}
3030
{{- end }}
31+
{{- if .Values.horizontalPodAutoscaler.customMetrics }}
32+
{{ toYaml .Values.horizontalPodAutoscaler.customMetrics | indent 4 }}
33+
{{- end }}
3134
{{- if .Values.horizontalPodAutoscaler.behavior }}
3235
behavior:
3336
{{ tpl (toYaml .Values.horizontalPodAutoscaler.behavior) $ | indent 4 }}

charts/k8s-service/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,8 @@ serviceAccount:
739739
# - maxReplicas (int) : The maximum amount of replicas allowed
740740
# - avgCpuUtilization (int) : The target average CPU utilization to be used with the metrics
741741
# - avgMemoryUtilization (int) : The target average Memory utilization to be used with the metrics
742+
# - customMetrics (list) : List of objects that define custom resource metrics for scaling.
743+
# See: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-multiple-metrics-and-custom-metrics
742744
# - behavior (object) : Configures the scaling behavior of the target in both Up and Down directions
743745
# (scaleUp and scaleDown fields respectively). If not set, the default
744746
# HPAScalingRules for scale up and scale down are used.

0 commit comments

Comments
 (0)