From 038d84d46bef30501fc235ae20dc24f6d087b8a1 Mon Sep 17 00:00:00 2001 From: Petr Drastil Date: Wed, 18 Aug 2021 13:20:32 +0200 Subject: [PATCH] Allow Dex auto scaling Signed-off-by: Petr Drastil --- charts/argo-cd/templates/_helpers.tpl | 13 ++++++++++--- charts/argo-cd/templates/dex/hpa.yaml | 28 +++++++++++++++++++++++++++ charts/argo-cd/values.yaml | 7 +++++++ 3 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 charts/argo-cd/templates/dex/hpa.yaml diff --git a/charts/argo-cd/templates/_helpers.tpl b/charts/argo-cd/templates/_helpers.tpl index be2927c2..5e1ffbb1 100644 --- a/charts/argo-cd/templates/_helpers.tpl +++ b/charts/argo-cd/templates/_helpers.tpl @@ -67,6 +67,13 @@ Create argocd repo-server name and version as used by the chart label. {{- printf "%s-%s" (include "argo-cd.fullname" .) .Values.repoServer.name | trunc 63 | trimSuffix "-" -}} {{- end -}} +{{/* +Create argocd dex-server name and version as used by the chart label. +*/}} +{{- define "argo-cd.dex.fullname" -}} +{{- printf "%s-%s" (include "argo-cd.fullname" .) .Values.dex.name | trunc 63 | trimSuffix "-" -}} +{{- end -}} + {{/* Create the name of the controller service account to use */}} @@ -174,7 +181,7 @@ Return the target Kubernetes version {{- default .Capabilities.KubeVersion.Version .Values.kubeVersionOverride }} {{- end -}} -{{/* +{{/* Argo Configuration Preset Values (Incluenced by Values configuration) */}} {{- define "argo-cd.config.presets" -}} @@ -183,11 +190,11 @@ ui.cssurl: "./custom/custom.styles.css" {{- end }} {{- end -}} -{{/* +{{/* Merge Argo Configuration with Preset Configuration */}} {{- define "argo-cd.config" -}} {{- if .Values.server.configEnabled -}} {{- toYaml (mergeOverwrite (default dict (fromYaml (include "argo-cd.config.presets" $))) .Values.server.config) }} {{- end -}} -{{- end -}} \ No newline at end of file +{{- end -}} diff --git a/charts/argo-cd/templates/dex/hpa.yaml b/charts/argo-cd/templates/dex/hpa.yaml new file mode 100644 index 00000000..3a654941 --- /dev/null +++ b/charts/argo-cd/templates/dex/hpa.yaml @@ -0,0 +1,28 @@ +{{- if and .Values.dex.enabled .Values.dex.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + labels: + {{- include "argo-cd.labels" (dict "context" . "component" .Values.dex.name "name" (printf "%s-hpa" .Values.dex.name)) | nindent 4 }} + name: {{ template "argo-cd.dex.fullname" . }}-hpa +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "argo-cd.dex.fullname" . }} + minReplicas: {{ .Values.dex.autoscaling.minReplicas }} + maxReplicas: {{ .Values.dex.autoscaling.maxReplicas }} + metrics: + {{- with .Values.dex.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ . }} + {{- end }} + {{- with .Values.dex.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ . }} + {{- end }} +{{- end }} diff --git a/charts/argo-cd/values.yaml b/charts/argo-cd/values.yaml index 137b4f08..16eb2948 100755 --- a/charts/argo-cd/values.yaml +++ b/charts/argo-cd/values.yaml @@ -220,6 +220,13 @@ dex: replicas: 1 + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 5 + targetCPUUtilizationPercentage: 50 + targetMemoryUtilizationPercentage: 50 + metrics: enabled: false service: