Allow Dex auto scaling

Signed-off-by: Petr Drastil <petr.drastil@gmail.com>
This commit is contained in:
Petr Drastil 2021-08-18 13:20:32 +02:00
parent d980d0fb28
commit 038d84d46b
No known key found for this signature in database
GPG key ID: B147517F4051E6ED
3 changed files with 45 additions and 3 deletions

View file

@ -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 -}}
{{- end -}}

View file

@ -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 }}

View file

@ -220,6 +220,13 @@ dex:
replicas: 1
autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 5
targetCPUUtilizationPercentage: 50
targetMemoryUtilizationPercentage: 50
metrics:
enabled: false
service: