From 83a08286f8775683f30e6fd2ac11f98dca889e80 Mon Sep 17 00:00:00 2001 From: iutx Date: Tue, 8 Nov 2022 21:42:34 +0800 Subject: [PATCH] feat: higress helm support kubernetes latest version Signed-off-by: iutx --- helm/higress/Chart.yaml | 2 +- helm/higress/templates/_helpers.tpl | 19 +++++++++++++++++++ helm/higress/templates/hpa.yaml | 2 +- helm/higress/values.yaml | 1 + helm/istio/Chart.lock | 2 +- helm/istio/Chart.yaml | 2 +- helm/istiod/templates/autoscale.yaml | 16 +++++++++++----- .../istiod/templates/poddisruptionbudget.yaml | 4 ++++ 8 files changed, 39 insertions(+), 9 deletions(-) diff --git a/helm/higress/Chart.yaml b/helm/higress/Chart.yaml index 23f2e70bf..9709787a0 100644 --- a/helm/higress/Chart.yaml +++ b/helm/higress/Chart.yaml @@ -7,6 +7,6 @@ keywords: - gateways name: higress sources: -- http://github.com/alibaba/higress +- https://github.com/alibaba/higress type: application version: 0.5.0 diff --git a/helm/higress/templates/_helpers.tpl b/helm/higress/templates/_helpers.tpl index 8a10b6c6d..bb49a66ee 100644 --- a/helm/higress/templates/_helpers.tpl +++ b/helm/higress/templates/_helpers.tpl @@ -1,3 +1,22 @@ +{{/* +Return the target Kubernetes version +*/}} +{{- define "capabilities.kubeVersion" -}} +{{- default .Capabilities.KubeVersion.Version .Values.kubeVersionOverride -}} +{{- end -}} + +{{/* +Return the appropriate apiVersion for autoscaling. +*/}} +{{- define "capabilities.autoscaling.apiVersion" -}} +{{- if semverCompare ">=1.23-0" (include "capabilities.kubeVersion" .) }} +{{- print "autoscaling/v2" -}} +{{- else -}} +{{- print "autoscaling/v2beta2" -}} +{{- end -}} +{{- end -}} + + {{- define "gateway.name" -}} {{- .Values.gateway.name | default "higress-gateway" -}} {{- end }} diff --git a/helm/higress/templates/hpa.yaml b/helm/higress/templates/hpa.yaml index 713260c8f..67708bbc7 100644 --- a/helm/higress/templates/hpa.yaml +++ b/helm/higress/templates/hpa.yaml @@ -1,5 +1,5 @@ {{- if .Values.gateway.autoscaling.enabled }} -apiVersion: autoscaling/v2beta2 +apiVersion: {{ include "capabilities.autoscaling.apiVersion" . }} kind: HorizontalPodAutoscaler metadata: name: {{ include "gateway.name" . }} diff --git a/helm/higress/values.yaml b/helm/higress/values.yaml index fd2b185d4..092ae8721 100644 --- a/helm/higress/values.yaml +++ b/helm/higress/values.yaml @@ -181,3 +181,4 @@ controller: maxReplicas: 5 targetCPUUtilizationPercentage: 80 +kubeVersionOverride: "" \ No newline at end of file diff --git a/helm/istio/Chart.lock b/helm/istio/Chart.lock index 40a90361f..07917ffd3 100644 --- a/helm/istio/Chart.lock +++ b/helm/istio/Chart.lock @@ -6,4 +6,4 @@ dependencies: repository: file://../istiod version: 1.12.0 digest: sha256:12dd680ac6eee11750941f56aab434cc35c5df09ac784a5ef8f5b84e0984f8c7 -generated: "2022-10-31T14:49:23.29643+08:00" +generated: "2022-11-08T21:31:35.660761+08:00" diff --git a/helm/istio/Chart.yaml b/helm/istio/Chart.yaml index a267f199a..b6241af29 100644 --- a/helm/istio/Chart.yaml +++ b/helm/istio/Chart.yaml @@ -3,7 +3,7 @@ appVersion: 1.12.0 description: Helm chart for deploying higress istio name: istio sources: -- http://github.com/alibaba/higress +- https://github.com/alibaba/higress dependencies: - name: base repository: "file://../base" diff --git a/helm/istiod/templates/autoscale.yaml b/helm/istiod/templates/autoscale.yaml index b8b14ad0b..43213d8ff 100644 --- a/helm/istiod/templates/autoscale.yaml +++ b/helm/istiod/templates/autoscale.yaml @@ -1,5 +1,9 @@ {{- if and .Values.pilot.autoscaleEnabled .Values.pilot.autoscaleMin .Values.pilot.autoscaleMax }} -apiVersion: autoscaling/v2beta1 +{{- if (semverCompare ">=1.23-0" .Capabilities.KubeVersion.GitVersion)}} +apiVersion: autoscaling/v2 +{{- else }} +apiVersion: autoscaling/v2beta2 +{{- end }} kind: HorizontalPodAutoscaler metadata: name: istiod{{- if not (eq .Values.revision "") }}-{{ .Values.revision }}{{- end }} @@ -18,9 +22,11 @@ spec: kind: Deployment name: istiod{{- if not (eq .Values.revision "") }}-{{ .Values.revision }}{{- end }} metrics: - - type: Resource - resource: - name: cpu - targetAverageUtilization: {{ .Values.pilot.cpu.targetAverageUtilization }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.pilot.cpu.targetAverageUtilization }} --- {{- end }} diff --git a/helm/istiod/templates/poddisruptionbudget.yaml b/helm/istiod/templates/poddisruptionbudget.yaml index 40b2e6015..454737a69 100644 --- a/helm/istiod/templates/poddisruptionbudget.yaml +++ b/helm/istiod/templates/poddisruptionbudget.yaml @@ -1,5 +1,9 @@ {{- if .Values.global.defaultPodDisruptionBudget.enabled }} +{{- if (semverCompare ">=1.21-0" .Capabilities.KubeVersion.GitVersion) }} +apiVersion: policy/v1 +{{- else }} apiVersion: policy/v1beta1 +{{- end }} kind: PodDisruptionBudget metadata: name: istiod{{- if not (eq .Values.revision "") }}-{{ .Values.revision }}{{- end }}