Skip to content

Commit

Permalink
Use autoscaling v2 for HPAs (#281)
Browse files Browse the repository at this point in the history
* fix susbtrate-telemetry autoscaling v2 template syntax

* use autoscaling/v2 for clusters that support it in common chart

* enable autoscaling in ci to validate templates

* fix carriage return in hpa templates

* use autoscaling/v2 for HPA in node chart

* add missing requires maxReplica in node ci values
  • Loading branch information
PierreBesson authored Aug 4, 2023
1 parent 9b3dea8 commit 9d9531c
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 6 deletions.
2 changes: 1 addition & 1 deletion charts/common/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: common
description: A generic helm chart for Kubernetes
type: application
version: 0.6.8
version: 0.7.0
maintainers:
- name: Parity
url: https://github.com/paritytech/helm-charts
3 changes: 3 additions & 0 deletions charts/common/ci/kind-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ service:
targetPort: 80
protocol: TCP

autoscaling:
enabled: true

env:
RANDOM_ENV_VAR: justsomerandom

Expand Down
18 changes: 17 additions & 1 deletion charts/common/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{{- if .Values.autoscaling.enabled }}
{{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: autoscaling/v2
{{- else -}}
apiVersion: autoscaling/v2beta1
{{- end }}
kind: HorizontalPodAutoscaler
metadata:
name: {{ template "common.fullname" . }}
Expand All @@ -18,12 +22,24 @@ spec:
- type: Resource
resource:
name: cpu
{{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.GitVersion }}
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- else -}}
targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.GitVersion }}
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- else -}}
targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion charts/node/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: node
description: A Helm chart to deploy Substrate/Polkadot nodes
type: application
version: 5.1.4
version: 5.1.5
maintainers:
- name: Parity
url: https://github.com/paritytech/helm-charts
Expand Down
2 changes: 1 addition & 1 deletion charts/node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This is intended behaviour. Make sure to run `git add -A` once again to stage ch

# Substrate/Polkadot node helm chart

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

## Maintainers

Expand Down
5 changes: 5 additions & 0 deletions charts/node/ci/kind-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ node:
whenScaled: Delete
image:
tag: v0.9.43
autoscaling:
enabled: true
targetCPU: 80
targetMemory: 80
maxReplicas: 2
2 changes: 1 addition & 1 deletion charts/node/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{ $fullname := include "node.fullname" . }}
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2beta2
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ $fullname }}
Expand Down
2 changes: 1 addition & 1 deletion charts/substrate-telemetry/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: "2.3.0"
version: "2.3.1"

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
5 changes: 5 additions & 0 deletions charts/substrate-telemetry/ci/kind-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
autoscaling:
shard:
enabled: true
frontend:
enabled: true
16 changes: 16 additions & 0 deletions charts/substrate-telemetry/templates/frontend-hpa.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{{- if .Values.autoscaling.frontend.enabled }}
{{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: autoscaling/v2
{{- else -}}
apiVersion: autoscaling/v2beta1
{{- end }}
kind: HorizontalPodAutoscaler
metadata:
name: telemetry-frontend
Expand All @@ -18,12 +22,24 @@ spec:
- type: Resource
resource:
name: cpu
{{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.GitVersion }}
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.frontend.targetCPUUtilizationPercentage }}
{{- else -}}
targetAverageUtilization: {{ .Values.autoscaling.frontend.targetCPUUtilizationPercentage }}
{{- end }}
{{- end }}
{{- if .Values.autoscaling.frontend.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
{{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.GitVersion }}
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.frontend.targetMemoryUtilizationPercentage }}
{{- else -}}
targetAverageUtilization: {{ .Values.autoscaling.frontend.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
{{- end }}
12 changes: 12 additions & 0 deletions charts/substrate-telemetry/templates/shard-hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,24 @@ spec:
- type: Resource
resource:
name: cpu
{{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.GitVersion }}
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.shard.targetCPUUtilizationPercentage }}
{{- else -}}
targetAverageUtilization: {{ .Values.autoscaling.shard.targetCPUUtilizationPercentage }}
{{- end }}
{{- end }}
{{- if .Values.autoscaling.shard.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
{{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.GitVersion }}
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.shard.targetMemoryUtilizationPercentage }}
{{- else -}}
targetAverageUtilization: {{ .Values.autoscaling.shard.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
{{- end }}

0 comments on commit 9d9531c

Please sign in to comment.