From 39bdc9abe4fa3df0b0c09eb33c5b22ac86664672 Mon Sep 17 00:00:00 2001 From: Patrick O'Brien Date: Tue, 13 Jun 2023 09:54:26 -0700 Subject: [PATCH] Reordering HPA spec.metrics to match HPA ordering (#3078) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Reordering HPA metrics to match HPA ordering 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 * add CHANGELOG entry --------- Signed-off-by: Patrick O’Brien --- .changelog/3078.changed.txt | 1 + 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 ++++++------ 5 files changed, 25 insertions(+), 24 deletions(-) create mode 100644 .changelog/3078.changed.txt diff --git a/.changelog/3078.changed.txt b/.changelog/3078.changed.txt new file mode 100644 index 0000000000..51d2fe54c6 --- /dev/null +++ b/.changelog/3078.changed.txt @@ -0,0 +1 @@ +Reordering HPA metrics to match HPA ordering \ No newline at end of file diff --git a/deploy/helm/sumologic/templates/logs/common/hpa.yaml b/deploy/helm/sumologic/templates/logs/common/hpa.yaml index 4f76e299dd..c3b8cfa3ba 100644 --- a/deploy/helm/sumologic/templates/logs/common/hpa.yaml +++ b/deploy/helm/sumologic/templates/logs/common/hpa.yaml @@ -19,18 +19,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 56e565256f..a5e605ebcb 100644 --- a/deploy/helm/sumologic/templates/logs/fluentd/hpa.yaml +++ b/deploy/helm/sumologic/templates/logs/fluentd/hpa.yaml @@ -19,12 +19,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: @@ -33,4 +27,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 c464c63dd1..b829622228 100644 --- a/deploy/helm/sumologic/templates/metrics/common/hpa.yaml +++ b/deploy/helm/sumologic/templates/metrics/common/hpa.yaml @@ -19,18 +19,18 @@ spec: minReplicas: {{ .Values.metadata.metrics.autoscaling.minReplicas }} maxReplicas: {{ .Values.metadata.metrics.autoscaling.maxReplicas }} metrics: +{{- if .Values.metadata.metrics.autoscaling.targetMemoryUtilizationPercentage }} - type: Resource resource: - name: cpu + name: memory target: type: Utilization - averageUtilization: {{ .Values.metadata.metrics.autoscaling.targetCPUUtilizationPercentage }} -{{- if .Values.metadata.metrics.autoscaling.targetMemoryUtilizationPercentage }} + averageUtilization: {{ .Values.metadata.metrics.autoscaling.targetMemoryUtilizationPercentage }} +{{- end }} - type: Resource resource: - name: memory + name: cpu target: type: Utilization - averageUtilization: {{ .Values.metadata.metrics.autoscaling.targetMemoryUtilizationPercentage }} -{{- end -}} + 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 49203f3aff..d25df62d76 100644 --- a/deploy/helm/sumologic/templates/metrics/fluentd/hpa.yaml +++ b/deploy/helm/sumologic/templates/metrics/fluentd/hpa.yaml @@ -19,12 +19,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: @@ -33,4 +27,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 -}}