Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#172] Update HPA #173

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions charts/maykin-utils-lib/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Changelog

## 0.2.0 (2025-01-28)

- [#172] Add templates for the HPAs for the webapp, the worker and nginx.
- Replace forgotten old library name `maykinhelmlib` with `maykinUtilsLib` in the celery config maps.
2 changes: 1 addition & 1 deletion charts/maykin-utils-lib/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ name: maykin-utils-lib
description: A Library Helm chart containing code shared between Maykin helm charts

type: library
version: 0.1.0
version: 0.2.0

2 changes: 1 addition & 1 deletion charts/maykin-utils-lib/templates/_celery-configmap.tpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- define "maykinhelmlib.celeryEnvConfigmap" -}}
{{- define "maykinUtilsLib.celeryEnvConfigmap" -}}
apiVersion: v1
kind: ConfigMap
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- define "maykinhelmlib.celeryLivenessConfigmap" -}}
{{- define "maykinUtilsLib.celeryLivenessConfigmap" -}}
apiVersion: v1
kind: ConfigMap
metadata:
Expand Down
52 changes: 52 additions & 0 deletions charts/maykin-utils-lib/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,56 @@ If release name contains chart name it will be used as a full name.
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "project.selectorLabels" -}}
app.kubernetes.io/name: {{ include "project.name" . }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "project.commonLabels" -}}
helm.sh/chart: {{ include "project.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}


{{/*
Project labels
*/}}
{{- define "project.labels" -}}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
{{ include "project.commonLabels" . }}
{{ include "project.selectorLabels" . }}
{{- end }}


{{/*
Create a default fully qualified name for the worker.
We truncate at 56 chars in order to provide space for the "-worker" suffix
*/}}
{{- define "project.workerFullname" -}}
{{ include "project.fullname" . | trunc 56 | trimSuffix "-" }}-worker
{{- end }}


{{/*
Create a default fully qualified name for NGINX.
We truncate at 57 chars in order to provide space for the "-nginx" suffix
*/}}
{{- define "project.nginxFullname" -}}
{{ include "project.fullname" . | trunc 57 | trimSuffix "-" }}-nginx
{{- end }}

{{/*
NGINX selector labels
*/}}
{{- define "project.nginxSelectorLabels" -}}
app.kubernetes.io/name: {{ include "project.nginxFullname" . }}
{{- end }}
38 changes: 38 additions & 0 deletions charts/maykin-utils-lib/templates/_nginx-hpa.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{{- define "maykinUtilsLib.nginxHpa" -}}
{{- if .Values.nginx.autoscaling.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "project.nginxFullname" . }}
labels:
{{- include "project.nginxSelectorLabels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "project.nginxFullname" . }}
minReplicas: {{ .Values.nginx.autoscaling.minReplicas }}
maxReplicas: {{ .Values.nginx.autoscaling.maxReplicas }}
metrics:
{{- if .Values.nginx.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.nginx.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.nginx.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ .Values.nginx.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- with .Values.nginx.autoscaling.behavior }}
behavior:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
{{- end -}}
38 changes: 38 additions & 0 deletions charts/maykin-utils-lib/templates/_webapp-hpa.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{{- define "maykinUtilsLib.webAppHpa" -}}
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "project.fullname" . }}
labels:
{{- include "project.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "project.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- with .Values.autoscaling.behavior }}
behavior:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
{{- end -}}
38 changes: 38 additions & 0 deletions charts/maykin-utils-lib/templates/_worker-hpa.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{{- define "maykinUtilsLib.workerHpa" -}}
{{- if .Values.worker.autoscaling.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "project.workerFullname" . }}
labels:
{{- include "project.workerSelectorLabels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "project.workerFullname" . }}
minReplicas: {{ .Values.worker.autoscaling.minReplicas }}
maxReplicas: {{ .Values.worker.autoscaling.maxReplicas }}
metrics:
{{- if .Values.worker.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.worker.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.worker.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ .Values.worker.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- with .Values.worker.autoscaling.behavior }}
behavior:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
{{- end -}}
7 changes: 6 additions & 1 deletion charts/objecten/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Changelog

## 2.7.0-beta.0 (2025-10-01)
## 2.8.0-beta.0 (2025-01-28)

- [#172] Add Horizontal Pod Autoscaler for the worker. Fix the deployment to look for the `.Values.worker.autoscaling.enabled` value instead of the `.Values.autoscaling.enabled` when setting the replicas of the worker.


## 2.7.0-beta.0 (2025-01-10)

- [#148] Replace the worker liveness probe with the `celery inspect active` command. This should detect when a worker is down and should not interrupt long running tasks.
- [#119] Update the syntax of the worker liveness probe. The worker probes now can be enabled/disabled with:
Expand Down
2 changes: 1 addition & 1 deletion charts/objecten/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: objecten
description: API om objecten te beheren die behoren bij een bepaald objecttype

type: application
version: 2.7.0-beta.0
version: 2.8.0-beta.0
appVersion: latest

dependencies:
Expand Down
6 changes: 4 additions & 2 deletions charts/objecten/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# objecten

![Version: 2.7.0-beta.0](https://img.shields.io/badge/Version-2.7.0--beta.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: latest](https://img.shields.io/badge/AppVersion-latest-informational?style=flat-square)
![Version: 2.8.0-beta.0](https://img.shields.io/badge/Version-2.8.0--beta.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: latest](https://img.shields.io/badge/AppVersion-latest-informational?style=flat-square)

API om objecten te beheren die behoren bij een bepaald objecttype

Expand All @@ -15,6 +15,7 @@ API om objecten te beheren die behoren bij een bepaald objecttype
| Key | Type | Default | Description |
|-----|------|---------|-------------|
| affinity | object | `{}` | |
| autoscaling.behaviour | object | `{}` | |
| autoscaling.enabled | bool | `false` | |
| autoscaling.maxReplicas | int | `100` | |
| autoscaling.minReplicas | int | `1` | |
Expand Down Expand Up @@ -161,13 +162,14 @@ API om objecten te beheren die behoren bij een bepaald objecttype
| settings.uwsgi.threads | string | `""` | |
| tags.redis | bool | `true` | |
| tolerations | list | `[]` | |
| worker.autoscaling.behaviour | object | `{}` | |
| worker.autoscaling.enabled | bool | `false` | |
| worker.autoscaling.maxReplicas | int | `100` | |
| worker.autoscaling.minReplicas | int | `1` | |
| worker.autoscaling.targetCPUUtilizationPercentage | int | `80` | |
| worker.autoscaling.targetMemoryUtilizationPercentage | int | `80` | |
| worker.concurrency | int | `4` | |
| worker.livenessProbe.enabled | bool | `true` | |
| worker.livenessProbe.enabled | bool | `false` | |
| worker.livenessProbe.exec.command[0] | string | `"/bin/sh"` | |
| worker.livenessProbe.exec.command[1] | string | `"-c"` | |
| worker.livenessProbe.exec.command[2] | string | `"celery --workdir src --app objects.celery inspect --destination celery@${HOSTNAME} active"` | |
Expand Down
2 changes: 1 addition & 1 deletion charts/objecten/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ metadata:
labels:
{{- include "objecten.workerLabels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
{{- if not .Values.worker.autoscaling.enabled }}
replicas: {{ .Values.worker.replicaCount }}
{{- end }}
selector:
Expand Down
41 changes: 41 additions & 0 deletions charts/objecten/templates/hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,46 @@ spec:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- with .Values.autoscaling.behavior }}
behavior:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
---
{{- if .Values.worker.autoscaling.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "objecten.workerFullname" . }}
labels:
{{- include "objecten.workerSelectorLabels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "objecten.workerFullname" . }}
minReplicas: {{ .Values.worker.autoscaling.minReplicas }}
maxReplicas: {{ .Values.worker.autoscaling.maxReplicas }}
metrics:
{{- if .Values.worker.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.worker.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.worker.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ .Values.worker.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- with .Values.worker.autoscaling.behavior }}
behavior:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}

2 changes: 2 additions & 0 deletions charts/objecten/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ autoscaling:
maxReplicas: 100
targetCPUUtilizationPercentage: 80
targetMemoryUtilizationPercentage: 80
behaviour: {}

pdb:
create: false
Expand Down Expand Up @@ -312,6 +313,7 @@ worker:
maxReplicas: 100
targetCPUUtilizationPercentage: 80
targetMemoryUtilizationPercentage: 80
behaviour: {}

flower:
enabled: true
Expand Down
7 changes: 6 additions & 1 deletion charts/openzaak/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Changelog

## 1.7.0-beta.0 (2025-10-01)
## 1.8.0-beta.0 (2025-01-28)

- [#172] Add Horizontal Pod Autoscaler for nginx. Fix the deployment to look for the `.Values.worker.autoscaling.enabled` value instead of the `.Values.autoscaling.enabled` when setting the replicas of the worker.


## 1.7.0-beta.0 (2025-01-10)

- [#148] Replace the worker liveness probe with the `celery inspect active` command. This should detect when a worker is down and should not interrupt long running tasks.
- [#119] Update the syntax of the worker liveness probe. The worker probes now can be enabled/disabled with:
Expand Down
2 changes: 1 addition & 1 deletion charts/openzaak/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: openzaak
description: Productiewaardige API's voor Zaakgericht Werken

type: application
version: 1.7.0-beta.0
version: 1.8.0-beta.0
appVersion: latest

dependencies:
Expand Down
2 changes: 1 addition & 1 deletion charts/openzaak/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# openzaak

![Version: 1.7.0-beta.0](https://img.shields.io/badge/Version-1.7.0--beta.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: latest](https://img.shields.io/badge/AppVersion-latest-informational?style=flat-square)
![Version: 1.8.0-beta.0](https://img.shields.io/badge/Version-1.8.0--beta.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: latest](https://img.shields.io/badge/AppVersion-latest-informational?style=flat-square)

Productiewaardige API's voor Zaakgericht Werken

Expand Down
2 changes: 1 addition & 1 deletion charts/openzaak/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ metadata:
labels:
{{- include "openzaak.workerLabels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
{{- if not .Values.worker.autoscaling.enabled }}
replicas: {{ .Values.worker.replicaCount }}
{{- end }}
selector:
Expand Down
Loading