From 0911c803fc8218c3cdac03e7aa3eb4feab7af458 Mon Sep 17 00:00:00 2001 From: Fran Mulero Date: Mon, 16 May 2022 11:41:46 +0200 Subject: [PATCH] [template] update template with latest standardisation changes (#10231) * Apply some fixes Signed-off-by: Fran Mulero * Use the new helper for HPA API version Signed-off-by: Fran Mulero * Remove extra whitespace Signed-off-by: Fran Mulero Co-authored-by: Miguel Ruiz Co-authored-by: Miguel Ruiz --- .../CHART_NAME/templates/clusterrolebinding.yaml | 1 - template/CHART_NAME/templates/hpa.yaml | 14 +++++++++++++- template/CHART_NAME/templates/role.yaml | 2 +- template/CHART_NAME/templates/servicemonitor.yaml | 2 +- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/template/CHART_NAME/templates/clusterrolebinding.yaml b/template/CHART_NAME/templates/clusterrolebinding.yaml index 3c9527984..03c0bc4c5 100644 --- a/template/CHART_NAME/templates/clusterrolebinding.yaml +++ b/template/CHART_NAME/templates/clusterrolebinding.yaml @@ -2,7 +2,6 @@ kind: ClusterRoleBinding apiVersion: {{ include "common.capabilities.rbac.apiVersion" . }} metadata: name: {{ template "common.names.fullname" . }} - namespace: {{ include "common.names.namespace" . | quote }} labels: {{- include "common.labels.standard" . | nindent 4 }} app.kubernetes.io/component: %%COMPONENT_NAME%% {{- if .Values.commonLabels }} diff --git a/template/CHART_NAME/templates/hpa.yaml b/template/CHART_NAME/templates/hpa.yaml index 3cc5de2a9..398728eac 100644 --- a/template/CHART_NAME/templates/hpa.yaml +++ b/template/CHART_NAME/templates/hpa.yaml @@ -1,5 +1,5 @@ {{- if .Values.%%MAIN_OBJECT_BLOCK%%.autoscaling.enabled }} -apiVersion: autoscaling/v2beta1 +apiVersion: {{ include "common.capabilities.hpa.apiVersion" . }} kind: HorizontalPodAutoscaler metadata: name: {{ include "common.names.fullname" . }} @@ -23,12 +23,24 @@ spec: - type: Resource resource: name: memory + {{- if semverCompare "<1.23-0" (include "common.capabilities.kubeVersion" .) }} targetAverageUtilization: {{ .Values.%%MAIN_OBJECT_BLOCK%%.autoscaling.targetMemory }} + {{- else }} + target: + type: Utilization + averageUtilization: {{ .Values.worker.autoscaling.targetMemory }} + {{- end }} {{- end }} {{- if .Values.%%MAIN_OBJECT_BLOCK%%.autoscaling.targetCPU }} - type: Resource resource: name: cpu + {{- if semverCompare "<1.23-0" (include "common.capabilities.kubeVersion" .) }} targetAverageUtilization: {{ .Values.%%MAIN_OBJECT_BLOCK%%.autoscaling.targetCPU }} + {{- else }} + target: + type: Utilization + averageUtilization: {{ .Values.worker.autoscaling.targetCPU }} + {{- end }} {{- end }} {{- end }} diff --git a/template/CHART_NAME/templates/role.yaml b/template/CHART_NAME/templates/role.yaml index 5f192cb34..dfdab9002 100644 --- a/template/CHART_NAME/templates/role.yaml +++ b/template/CHART_NAME/templates/role.yaml @@ -1,6 +1,6 @@ {{ if .Values.rbac.create }} kind: Role -apiVersion: rbac.authorization.k8s.io/v1 +apiVersion: {{ include "common.capabilities.rbac.apiVersion" . }} metadata: name: {{ include "common.names.fullname" . }} namespace: {{ include "common.names.namespace" . | quote }} diff --git a/template/CHART_NAME/templates/servicemonitor.yaml b/template/CHART_NAME/templates/servicemonitor.yaml index 73423ae63..6cc8e051d 100644 --- a/template/CHART_NAME/templates/servicemonitor.yaml +++ b/template/CHART_NAME/templates/servicemonitor.yaml @@ -45,5 +45,5 @@ spec: {{- end }} namespaceSelector: matchNames: - - {{ .Release.Namespace }} + - {{ include "common.names.namespace" . | quote }} {{- end }}