Skip to content

Commit

Permalink
Merge pull request #311 from mintel/infra-32867-vpa
Browse files Browse the repository at this point in the history
Add flag to enable VPA autoscaling
  • Loading branch information
jtdoepke authored Feb 9, 2024
2 parents 0352b54 + 841550a commit 653c468
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 8 deletions.
4 changes: 4 additions & 0 deletions charts/standard-application-stack/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [v5.19.0] - 2024-02-09
### Added
- Flag to enable VPA autoscaling

## [v5.18.0] - 2024-01-16
### Changed
- Updated standard-application-stack default image tag from v0.1.0 to v0.0.0
Expand Down
2 changes: 1 addition & 1 deletion charts/standard-application-stack/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 5.18.0
version: 5.19.0

dependencies:
- name: redis
Expand Down
5 changes: 3 additions & 2 deletions charts/standard-application-stack/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# standard-application-stack

![Version: 5.18.0](https://img.shields.io/badge/Version-5.18.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)
![Version: 5.19.0](https://img.shields.io/badge/Version-5.19.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)

A generic chart to support most common application requirements

Expand Down Expand Up @@ -361,7 +361,8 @@ A generic chart to support most common application requirements
| topologySpreadConstraints.zone.enabled | bool | `true` | |
| topologySpreadConstraints.zone.maxSkew | int | `1` | |
| useHostNetwork | bool | `false` | If true, use the host network for the main deployment. |
| verticalPodAutoscaler | object | `{"enabled":true}` | Configuration for creating a VerticalPodAutoscaler for this app. Currently only supports recommendations-only mode. |
| verticalPodAutoscaler | object | `{"autoscalingEnabled":false,"enabled":true}` | Configuration for creating a VerticalPodAutoscaler for this app. Currently only supports recommendations-only mode. |
| verticalPodAutoscaler.autoscalingEnabled | bool | `false` | Set to true to automatically apply the resource recommendations of VerticalPodAutoscaler. |
| verticalPodAutoscaler.enabled | bool | `true` | Set to true to create a VerticalPodAutoscaler. |
| volumeMounts | list | `[]` | A list of volume mounts to be added to the pod |
| volumes | string | `nil` | A list of volumes to be added to the pod |
Expand Down
4 changes: 2 additions & 2 deletions charts/standard-application-stack/templates/vpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ spec:
{{ end }}
name: {{ include "mintel_common.fullname" . }}
updatePolicy:
updateMode: "Off"
updateMode: {{ if $.Values.verticalPodAutoscaler.autoscalingEnabled }}"Auto"{{ else }}"Off"{{ end }}
{{- end }}

{{- range .Values.cronjobs.jobs }}
Expand All @@ -46,7 +46,7 @@ spec:
kind: CronJob
name: {{ include "mintel_common.fullname" $data }}
updatePolicy:
updateMode: "Off"
updateMode: {{ if $.Values.verticalPodAutoscaler.autoscalingEnabled }}"Auto"{{ else }}"Off"{{ end }}
{{- end }}

{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,31 @@ Creates a VerticalPodAutoscaler for a StatefulSet:
name: example-app
updatePolicy:
updateMode: "Off"
Creates a VerticalPodAutoscaler with autoscaling enabled:
1: |
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
annotations:
app.mintel.com/placeholder: placeholder
labels:
app.kubernetes.io/component: app
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: example-app
app.mintel.com/application: example-app
app.mintel.com/component: example-app
app.mintel.com/env: qa
app.mintel.com/region: ${CLUSTER_REGION}
name: example-app
name: deployment-example-app
namespace: test-namespace
spec:
targetRef:
apiVersion: apps/v1
kind: Deployment
name: example-app
updatePolicy:
updateMode: Auto
Only creates VerticalPodAutoscaler for CronJobs if cronjobsOnly is true:
1: |
apiVersion: autoscaling.k8s.io/v1
Expand Down
57 changes: 54 additions & 3 deletions charts/standard-application-stack/tests/vpa_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,20 @@ templates:
release:
namespace: test-namespace
tests:
- it: Doesn't create a VerticalPodAutoscaler
set:
global.clusterEnv: qa
verticalPodAutoscaler.enabled: false
statefulset: false
cronjobsOnly: false
asserts:
- hasDocuments:
count: 0

- it: Creates a VerticalPodAutoscaler for a Deployment
set:
global.clusterEnv: qa
vpa.enabled: true
verticalPodAutoscaler.enabled: true
statefulset: false
cronjobsOnly: false
asserts:
Expand All @@ -31,11 +41,14 @@ tests:
- equal:
path: spec.targetRef.name
value: example-app
- equal:
path: spec.updatePolicy.updateMode
value: "Off"

- it: Creates a VerticalPodAutoscaler for a StatefulSet
set:
global.clusterEnv: qa
vpa.enabled: true
verticalPodAutoscaler.enabled: true
statefulset: true
cronjobsOnly: false
asserts:
Expand All @@ -59,11 +72,14 @@ tests:
- equal:
path: spec.targetRef.name
value: example-app
- equal:
path: spec.updatePolicy.updateMode
value: "Off"

- it: Only creates VerticalPodAutoscaler for CronJobs if cronjobsOnly is true
set:
global.clusterEnv: qa
vpa.enabled: true
verticalPodAutoscaler.enabled: true
cronjobsOnly: true
cronjobs.jobs:
- name: daily
Expand Down Expand Up @@ -100,3 +116,38 @@ tests:
- equal:
path: spec.targetRef.name
value: example-app-daily
- equal:
path: spec.updatePolicy.updateMode
value: "Off"

- it: Creates a VerticalPodAutoscaler with autoscaling enabled
set:
global.clusterEnv: qa
verticalPodAutoscaler.enabled: true
verticalPodAutoscaler.autoscalingEnabled: true
statefulset: false
cronjobsOnly: false
asserts:
- matchSnapshot: {} # Check for regressions and unexpected changes.
- isKind:
of: VerticalPodAutoscaler
- equal:
path: metadata.namespace
value: test-namespace
- hasDocuments:
count: 1
- equal:
path: metadata.name
value: deployment-example-app
- equal:
path: spec.targetRef.apiVersion
value: apps/v1
- equal:
path: spec.targetRef.kind
value: Deployment
- equal:
path: spec.targetRef.name
value: example-app
- equal:
path: spec.updatePolicy.updateMode
value: Auto
2 changes: 2 additions & 0 deletions charts/standard-application-stack/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1382,3 +1382,5 @@ localstack:
verticalPodAutoscaler:
# -- Set to true to create a VerticalPodAutoscaler.
enabled: true
# -- Set to true to automatically apply the resource recommendations of VerticalPodAutoscaler.
autoscalingEnabled: false

0 comments on commit 653c468

Please sign in to comment.