From 8f57e93b3d7c993465b3683896e8b84f427d9b4f Mon Sep 17 00:00:00 2001 From: SIRICA1 Date: Fri, 10 Mar 2023 16:58:08 +0000 Subject: [PATCH] feat(argo-cd): Replace Application Controller StatefullSet with a Deployment and enabled autoscaling Signed-off-by: SIRICA1 --- charts/argo-cd/Chart.yaml | 6 +-- charts/argo-cd/README.md | 18 ++++---- .../{statefulset.yaml => deployment.yaml} | 10 ++--- .../argocd-application-controller/hpa.yaml | 44 +++++++++++++++++++ 4 files changed, 62 insertions(+), 16 deletions(-) rename charts/argo-cd/templates/argocd-application-controller/{statefulset.yaml => deployment.yaml} (97%) create mode 100644 charts/argo-cd/templates/argocd-application-controller/hpa.yaml diff --git a/charts/argo-cd/Chart.yaml b/charts/argo-cd/Chart.yaml index 663a1081..a42254e3 100644 --- a/charts/argo-cd/Chart.yaml +++ b/charts/argo-cd/Chart.yaml @@ -3,7 +3,7 @@ appVersion: v2.6.4 kubeVersion: ">=1.22.0-0" description: A Helm chart for Argo CD, a declarative, GitOps continuous delivery tool for Kubernetes. name: argo-cd -version: 5.25.0 +version: 5.25.1 home: https://github.com/argoproj/argo-helm icon: https://argo-cd.readthedocs.io/en/stable/assets/logo.png sources: @@ -23,5 +23,5 @@ dependencies: condition: redis-ha.enabled annotations: artifacthub.io/changes: | - - kind: added - description: Add parameter env to redis exporter + - kind: changed + description: Replace Application Controller StatefullSet with a Deployment and enabled autoscaling diff --git a/charts/argo-cd/README.md b/charts/argo-cd/README.md index b5e4adba..542149a7 100644 --- a/charts/argo-cd/README.md +++ b/charts/argo-cd/README.md @@ -29,7 +29,9 @@ redis-ha: enabled: true controller: - replicas: 1 + autoscaling: + enabled: true + minReplicas: 2 server: autoscaling: @@ -72,7 +74,7 @@ When installing Argo CD using this helm chart the user should have a similar exp To update the templates and default settings in `values.yaml` it may come in handy to look up the diff of the `manifests/install.yaml` between two versions accordingly. This can either be done directly via github and look for `manifests/install.yaml`: -https://github.com/argoproj/argo-cd/compare/v1.8.7...v2.0.0#files_bucket + Or you clone the repository and do a local `git-diff`: @@ -171,9 +173,9 @@ done This version **removes support for**: -- deprecated repository credentials (parameter `configs.repositoryCredentials`) -- option to run application controller as a Deployment -- the parameters `server.additionalApplications` and `server.additionalProjects` +* deprecated repository credentials (parameter `configs.repositoryCredentials`) +* option to run application controller as a Deployment +* the parameters `server.additionalApplications` and `server.additionalProjects` Please carefully read the following section if you are using these parameters! @@ -351,8 +353,8 @@ server: ## Prerequisites -- Kubernetes: `>=1.22.0-0` -- Helm v3.0.0+ +* Kubernetes: `>=1.22.0-0` +* Helm v3.0.0+ ## Installing the Chart @@ -956,7 +958,7 @@ server: ### Option 2 - Redis HA -This option uses the following third-party chart to bootstrap a clustered Redis: https://github.com/DandyDeveloper/charts/tree/master/charts/redis-ha. +This option uses the following third-party chart to bootstrap a clustered Redis: . For all available configuration options, please read upstream README and/or chart source. The main options are listed here: diff --git a/charts/argo-cd/templates/argocd-application-controller/statefulset.yaml b/charts/argo-cd/templates/argocd-application-controller/deployment.yaml similarity index 97% rename from charts/argo-cd/templates/argocd-application-controller/statefulset.yaml rename to charts/argo-cd/templates/argocd-application-controller/deployment.yaml index ad8cbc1b..039dfdf0 100644 --- a/charts/argo-cd/templates/argocd-application-controller/statefulset.yaml +++ b/charts/argo-cd/templates/argocd-application-controller/deployment.yaml @@ -1,7 +1,7 @@ apiVersion: apps/v1 -kind: StatefulSet +kind: Deployment metadata: - {{- with (mergeOverwrite (deepCopy .Values.global.statefulsetAnnotations) .Values.controller.statefulsetAnnotations) }} + {{- with (mergeOverwrite (deepCopy .Values.global.deploymentAnnotations) .Values.controller.deploymentAnnotations) }} annotations: {{- range $key, $value := . }} {{ $key }}: {{ $value | quote }} @@ -11,10 +11,10 @@ metadata: labels: {{- include "argo-cd.labels" (dict "context" . "component" .Values.controller.name "name" .Values.controller.name) | nindent 4 }} spec: + {{- if not .Values.controller.autoscaling.enabled }} replicas: {{ .Values.controller.replicas }} - # TODO: Remove for breaking release as history limit cannot be patched - revisionHistoryLimit: 5 - serviceName: {{ include "argo-cd.controller.fullname" . }} + {{- end }} + revisionHistoryLimit: {{ .Values.global.revisionHistoryLimit }} selector: matchLabels: {{- include "argo-cd.selectorLabels" (dict "context" . "name" .Values.controller.name) | nindent 6 }} diff --git a/charts/argo-cd/templates/argocd-application-controller/hpa.yaml b/charts/argo-cd/templates/argocd-application-controller/hpa.yaml new file mode 100644 index 00000000..da10e2ed --- /dev/null +++ b/charts/argo-cd/templates/argocd-application-controller/hpa.yaml @@ -0,0 +1,44 @@ +{{- if .Values.controller.autoscaling.enabled }} +apiVersion: {{ include "argo-cd.apiVersion.autoscaling" . }} +kind: HorizontalPodAutoscaler +metadata: + labels: + {{- include "argo-cd.labels" (dict "context" . "component" .Values.controller.name "name" (printf "%s-hpa" .Values.controller.name)) | nindent 4 }} + name: {{ template "argo-cd.controller.fullname" . }}-hpa +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "argo-cd.controller.fullname" . }} + minReplicas: {{ .Values.controller.autoscaling.minReplicas }} + maxReplicas: {{ .Values.controller.autoscaling.maxReplicas }} + metrics: + {{- with .Values.controller.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + {{- if eq (include "argo-cd.apiVersion.autoscaling" $) "autoscaling/v2beta1" }} + targetAverageUtilization: {{ . }} + {{- else }} + target: + averageUtilization: {{ . }} + type: Utilization + {{- end }} + {{- end }} + {{- with .Values.controller.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + {{- if eq (include "argo-cd.apiVersion.autoscaling" $) "autoscaling/v2beta1" }} + targetAverageUtilization: {{ . }} + {{- else }} + target: + averageUtilization: {{ . }} + type: Utilization + {{- end }} + {{- end }} + {{- with .Values.controller.autoscaling.behavior }} + behavior: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }}