feat(argo-cd): Added apiVersion switch for autoscaling resources (#1375)

* Added apiVersion switch for autoscaling

Signed-off-by: dn <dn@nuvotex.de>

* bumped chart version
added changelog

Signed-off-by: dn <dn@nuvotex.de>

* updated docs with helm-docs 1.9.1

Signed-off-by: dn <dn@nuvotex.de>

* added new line end of file (lint issue)

Signed-off-by: dn <dn@nuvotex.de>

* replaced linebreaks in chart.yaml with LF

Signed-off-by: dn <dn@nuvotex.de>

* Apply changes from code review

Signed-off-by: Marco Kilchhofer <mkilchhofer@users.noreply.github.com>

Co-authored-by: Marco Kilchhofer <mkilchhofer@users.noreply.github.com>
This commit is contained in:
Daniel Nachtrub 2022-07-14 15:02:52 +02:00 committed by GitHub
parent 1fda562239
commit 9c245d4e65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 44 additions and 4 deletions

View file

@ -2,7 +2,7 @@ apiVersion: v2
appVersion: v2.4.6 appVersion: v2.4.6
description: A Helm chart for Argo CD, a declarative, GitOps continuous delivery tool for Kubernetes. description: A Helm chart for Argo CD, a declarative, GitOps continuous delivery tool for Kubernetes.
name: argo-cd name: argo-cd
version: 4.9.13 version: 4.9.14
home: https://github.com/argoproj/argo-helm home: https://github.com/argoproj/argo-helm
icon: https://argo-cd.readthedocs.io/en/stable/assets/logo.png icon: https://argo-cd.readthedocs.io/en/stable/assets/logo.png
keywords: keywords:
@ -21,4 +21,4 @@ dependencies:
condition: redis-ha.enabled condition: redis-ha.enabled
annotations: annotations:
artifacthub.io/changes: | artifacthub.io/changes: |
- [Changed]: Update to app version 2.4.6" - [Changed]: Autoscaling now uses autoscaling/v2 apiVersion on kubernetes >= 1.23

View file

@ -213,6 +213,7 @@ NAME: my-release
| Key | Type | Default | Description | | Key | Type | Default | Description |
|-----|------|---------|-------------| |-----|------|---------|-------------|
| apiVersionOverrides.autoscaling | string | `""` | String to override apiVersion of autoscaling rendered by this helm chart |
| apiVersionOverrides.certmanager | string | `""` | String to override apiVersion of certmanager resources rendered by this helm chart | | apiVersionOverrides.certmanager | string | `""` | String to override apiVersion of certmanager resources rendered by this helm chart |
| apiVersionOverrides.ingress | string | `""` | String to override apiVersion of ingresses rendered by this helm chart | | apiVersionOverrides.ingress | string | `""` | String to override apiVersion of ingresses rendered by this helm chart |
| configs.clusterCredentials | list | `[]` (See [values.yaml]) | Provide one or multiple [external cluster credentials] | | configs.clusterCredentials | list | `[]` (See [values.yaml]) | Provide one or multiple [external cluster credentials] |

View file

@ -219,6 +219,19 @@ Return the appropriate apiVersion for ingress
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{/*
Return the appropriate apiVersion for autoscaling
*/}}
{{- define "argo-cd.autoscaling.apiVersion" -}}
{{- if .Values.apiVersionOverrides.autoscaling -}}
{{- print .Values.apiVersionOverrides.autoscaling -}}
{{- else if semverCompare "<1.23-0" (include "argo-cd.kubeVersion" $) -}}
{{- print "autoscaling/v2beta1" -}}
{{- else -}}
{{- print "autoscaling/v2" -}}
{{- end -}}
{{- end -}}
{{/* {{/*
Return the target Kubernetes version Return the target Kubernetes version
*/}} */}}

View file

@ -1,5 +1,5 @@
{{- if .Values.repoServer.autoscaling.enabled }} {{- if .Values.repoServer.autoscaling.enabled }}
apiVersion: autoscaling/v2beta1 apiVersion: {{ include "argo-cd.autoscaling.apiVersion" . }}
kind: HorizontalPodAutoscaler kind: HorizontalPodAutoscaler
metadata: metadata:
labels: labels:
@ -17,12 +17,24 @@ spec:
- type: Resource - type: Resource
resource: resource:
name: memory name: memory
{{- if eq (include "argo-cd.autoscaling.apiVersion" $) "autoscaling/v2beta1" }}
targetAverageUtilization: {{ . }} targetAverageUtilization: {{ . }}
{{- else }}
target:
averageUtilization: {{ . }}
type: Utilization
{{- end }}
{{- end }} {{- end }}
{{- with .Values.repoServer.autoscaling.targetCPUUtilizationPercentage }} {{- with .Values.repoServer.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource - type: Resource
resource: resource:
name: cpu name: cpu
{{- if eq (include "argo-cd.autoscaling.apiVersion" $) "autoscaling/v2beta1" }}
targetAverageUtilization: {{ . }} targetAverageUtilization: {{ . }}
{{- else }}
target:
averageUtilization: {{ . }}
type: Utilization
{{- end }}
{{- end }} {{- end }}
{{- end }} {{- end }}

View file

@ -1,5 +1,5 @@
{{- if .Values.server.autoscaling.enabled }} {{- if .Values.server.autoscaling.enabled }}
apiVersion: autoscaling/v2beta1 apiVersion: {{ include "argo-cd.autoscaling.apiVersion" . }}
kind: HorizontalPodAutoscaler kind: HorizontalPodAutoscaler
metadata: metadata:
labels: labels:
@ -17,12 +17,24 @@ spec:
- type: Resource - type: Resource
resource: resource:
name: memory name: memory
{{- if eq (include "argo-cd.autoscaling.apiVersion" $) "autoscaling/v2beta1" }}
targetAverageUtilization: {{ . }} targetAverageUtilization: {{ . }}
{{- else }}
target:
averageUtilization: {{ . }}
type: Utilization
{{- end }}
{{- end }} {{- end }}
{{- with .Values.server.autoscaling.targetCPUUtilizationPercentage }} {{- with .Values.server.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource - type: Resource
resource: resource:
name: cpu name: cpu
{{- if eq (include "argo-cd.autoscaling.apiVersion" $) "autoscaling/v2beta1" }}
targetAverageUtilization: {{ . }} targetAverageUtilization: {{ . }}
{{- else }}
target:
averageUtilization: {{ . }}
type: Utilization
{{- end }}
{{- end }} {{- end }}
{{- end }} {{- end }}

View file

@ -53,6 +53,8 @@ apiVersionOverrides:
certmanager: "" # cert-manager.io/v1 certmanager: "" # cert-manager.io/v1
# -- String to override apiVersion of ingresses rendered by this helm chart # -- String to override apiVersion of ingresses rendered by this helm chart
ingress: "" # networking.k8s.io/v1beta1 ingress: "" # networking.k8s.io/v1beta1
# -- String to override apiVersion of autoscaling rendered by this helm chart
autoscaling: "" # autoscaling/v2
# -- Create clusterroles that extend existing clusterroles to interact with argo-cd crds # -- Create clusterroles that extend existing clusterroles to interact with argo-cd crds
## Ref: https://kubernetes.io/docs/reference/access-authn-authz/rbac/#aggregated-clusterroles ## Ref: https://kubernetes.io/docs/reference/access-authn-authz/rbac/#aggregated-clusterroles