From 7b06a4fa41c5131df3bd42a56082961c8cff7649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20O=E2=80=99Brien?= Date: Wed, 7 Jun 2023 11:01:39 -0700 Subject: [PATCH] Reordering HPA metrics to match HPA ordering MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This addresses an issue when using ArgoCD (and maybe other GitOps operators) where Kubernetes reorders the objects under the spec.metrics key thus causing Sync issues with ArgoCD. Originally reported to the ArgoCD project here: https://github.com/argoproj/argo-cd/issues/1079 Originally reported to the Kubernetes project here: https://github.com/kubernetes/kubernetes/issues/74099 Other projects and companies have also addressed this by simply reordering the metrics section: * https://github.com/kubernetes/ingress-nginx/pull/10043 * https://github.com/nginxinc/kubernetes-ingress/pull/3773 * https://github.com/grafana/helm-charts/pull/758 * https://github.com/open-telemetry/opentelemetry-helm-charts/pull/103 * https://github.com/Nextdoor/k8s-charts/pull/102 Signed-off-by: Patrick O’Brien --- deploy/helm/sumologic/templates/logs/common/hpa.yaml | 12 ++++++------ .../helm/sumologic/templates/logs/fluentd/hpa.yaml | 12 ++++++------ .../helm/sumologic/templates/metrics/common/hpa.yaml | 12 ++++++------ .../sumologic/templates/metrics/fluentd/hpa.yaml | 12 ++++++------ 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/deploy/helm/sumologic/templates/logs/common/hpa.yaml b/deploy/helm/sumologic/templates/logs/common/hpa.yaml index 34ee9b0c0f..8189184ba0 100644 --- a/deploy/helm/sumologic/templates/logs/common/hpa.yaml +++ b/deploy/helm/sumologic/templates/logs/common/hpa.yaml @@ -18,18 +18,18 @@ spec: minReplicas: {{ .Values.metadata.logs.autoscaling.minReplicas }} maxReplicas: {{ .Values.metadata.logs.autoscaling.maxReplicas }} metrics: +{{- if .Values.metadata.logs.autoscaling.targetMemoryUtilizationPercentage }} - type: Resource resource: - name: cpu + name: memory target: type: Utilization - averageUtilization: {{ .Values.metadata.logs.autoscaling.targetCPUUtilizationPercentage }} -{{- if .Values.metadata.logs.autoscaling.targetMemoryUtilizationPercentage }} + averageUtilization: {{ .Values.metadata.logs.autoscaling.targetMemoryUtilizationPercentage }} +{{- end }} - type: Resource resource: - name: memory + name: cpu target: type: Utilization - averageUtilization: {{ .Values.metadata.logs.autoscaling.targetMemoryUtilizationPercentage }} -{{- end -}} + averageUtilization: {{ .Values.metadata.logs.autoscaling.targetCPUUtilizationPercentage }} {{- end -}} diff --git a/deploy/helm/sumologic/templates/logs/fluentd/hpa.yaml b/deploy/helm/sumologic/templates/logs/fluentd/hpa.yaml index d6cdd0df4b..9a609e8ea6 100644 --- a/deploy/helm/sumologic/templates/logs/fluentd/hpa.yaml +++ b/deploy/helm/sumologic/templates/logs/fluentd/hpa.yaml @@ -18,12 +18,6 @@ spec: minReplicas: {{ .Values.fluentd.logs.autoscaling.minReplicas }} maxReplicas: {{ .Values.fluentd.logs.autoscaling.maxReplicas }} metrics: - - type: Resource - resource: - name: cpu - target: - type: Utilization - averageUtilization: {{ .Values.fluentd.logs.autoscaling.targetCPUUtilizationPercentage }} {{- if .Values.fluentd.logs.autoscaling.targetMemoryUtilizationPercentage }} - type: Resource resource: @@ -32,4 +26,10 @@ spec: type: Utilization averageUtilization: {{ .Values.fluentd.logs.autoscaling.targetMemoryUtilizationPercentage }} {{- end -}} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.fluentd.logs.autoscaling.targetCPUUtilizationPercentage }} {{- end -}} diff --git a/deploy/helm/sumologic/templates/metrics/common/hpa.yaml b/deploy/helm/sumologic/templates/metrics/common/hpa.yaml index 3d3659321f..0f70439d92 100644 --- a/deploy/helm/sumologic/templates/metrics/common/hpa.yaml +++ b/deploy/helm/sumologic/templates/metrics/common/hpa.yaml @@ -18,12 +18,6 @@ spec: minReplicas: {{ .Values.metadata.metrics.autoscaling.minReplicas }} maxReplicas: {{ .Values.metadata.metrics.autoscaling.maxReplicas }} metrics: - - type: Resource - resource: - name: cpu - target: - type: Utilization - averageUtilization: {{ .Values.metadata.metrics.autoscaling.targetCPUUtilizationPercentage }} {{- if .Values.metadata.metrics.autoscaling.targetMemoryUtilizationPercentage }} - type: Resource resource: @@ -32,4 +26,10 @@ spec: type: Utilization averageUtilization: {{ .Values.metadata.metrics.autoscaling.targetMemoryUtilizationPercentage }} {{- end -}} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.metadata.metrics.autoscaling.targetCPUUtilizationPercentage }} {{- end -}} diff --git a/deploy/helm/sumologic/templates/metrics/fluentd/hpa.yaml b/deploy/helm/sumologic/templates/metrics/fluentd/hpa.yaml index 1fd39a3777..4bb03c1a80 100644 --- a/deploy/helm/sumologic/templates/metrics/fluentd/hpa.yaml +++ b/deploy/helm/sumologic/templates/metrics/fluentd/hpa.yaml @@ -18,12 +18,6 @@ spec: minReplicas: {{ .Values.fluentd.metrics.autoscaling.minReplicas }} maxReplicas: {{ .Values.fluentd.metrics.autoscaling.maxReplicas }} metrics: - - type: Resource - resource: - name: cpu - target: - type: Utilization - averageUtilization: {{ .Values.fluentd.metrics.autoscaling.targetCPUUtilizationPercentage }} {{- if .Values.fluentd.metrics.autoscaling.targetMemoryUtilizationPercentage }} - type: Resource resource: @@ -32,4 +26,10 @@ spec: type: Utilization averageUtilization: {{ .Values.fluentd.metrics.autoscaling.targetMemoryUtilizationPercentage }} {{- end -}} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.fluentd.metrics.autoscaling.targetCPUUtilizationPercentage }} {{- end -}}