From 21f2edb27cd0c9a386ca809260d72ddc98fc2211 Mon Sep 17 00:00:00 2001 From: Antoine Date: Sat, 20 Jul 2024 19:11:34 +0200 Subject: [PATCH] firezone-gateway: support autoscaling (#28) * firezone-gateway: support autoscaling * firezone-gateway: bump version --- firezone-gateway/Chart.yaml | 4 +-- firezone-gateway/templates/deployment.yaml | 2 ++ firezone-gateway/templates/hpa.yaml | 32 ++++++++++++++++++++++ firezone-gateway/templates/pdb.yml | 24 ++++++++++++++++ firezone-gateway/values.yaml | 14 ++++++++++ 5 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 firezone-gateway/templates/hpa.yaml create mode 100644 firezone-gateway/templates/pdb.yml diff --git a/firezone-gateway/Chart.yaml b/firezone-gateway/Chart.yaml index b5f0ae5..005a138 100644 --- a/firezone-gateway/Chart.yaml +++ b/firezone-gateway/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v2 name: firezone-gateway -version: 0.10.0 -appVersion: "1.1.1" +version: 0.11.0 +appVersion: "1.1.2" type: application description: A Helm chart for deploying a firezone gateway icon: https://raw.githubusercontent.com/firezone/firezone/main/website/public/images/logo-main.svg diff --git a/firezone-gateway/templates/deployment.yaml b/firezone-gateway/templates/deployment.yaml index 1a19c15..ebdf2cd 100644 --- a/firezone-gateway/templates/deployment.yaml +++ b/firezone-gateway/templates/deployment.yaml @@ -5,7 +5,9 @@ metadata: labels: {{- include "firezone-gateway.labels" . | nindent 4 }} spec: + {{- if not .Values.autoscaling.enabled }} replicas: {{ .Values.replicas }} + {{- end }} revisionHistoryLimit: {{ .Values.revisionHistoryLimit }} selector: matchLabels: diff --git a/firezone-gateway/templates/hpa.yaml b/firezone-gateway/templates/hpa.yaml new file mode 100644 index 0000000..262df40 --- /dev/null +++ b/firezone-gateway/templates/hpa.yaml @@ -0,0 +1,32 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "firezone-gateway.fullname" . }} + labels: + {{- include "firezone-gateway.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "firezone-gateway.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 }} +{{- end }} diff --git a/firezone-gateway/templates/pdb.yml b/firezone-gateway/templates/pdb.yml new file mode 100644 index 0000000..9a9ef79 --- /dev/null +++ b/firezone-gateway/templates/pdb.yml @@ -0,0 +1,24 @@ +{{- if .Values.pdb.enabled }} +apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + name: {{ include "firezone-gateway.fullname" . }} + labels: + {{- include "firezone-gateway.labels" . | nindent 4 }} + {{- with .Values.pdb.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{ with .Values.pdb.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- with .Values.pdb.maxUnavailable }} + maxUnavailable: {{ . }} + {{- else }} + minAvailable: {{ .Values.pdb.minAvailable | default 0 }} + {{- end }} + selector: + matchLabels: + {{- include "firezone-gateway.selectorLabels" . | nindent 6 }} +{{- end }} diff --git a/firezone-gateway/values.yaml b/firezone-gateway/values.yaml index a99b79b..bff2fc4 100644 --- a/firezone-gateway/values.yaml +++ b/firezone-gateway/values.yaml @@ -59,3 +59,17 @@ serviceAccount: # The name of the service account to use. # If not set and create is true, a name is generated using the fullname template name: "" + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +pdb: + enabled: false + labels: {} + annotations: {} + minAvailable: "" + maxUnavailable: ""