From 7c5c9d38ebed2e9badfb9018117bba957456955d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Beaufils?= Date: Tue, 11 Mar 2025 14:25:22 +0100 Subject: [PATCH] feat: add trafficDistribution feature on service of the Helm chart MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémi Beaufils --- chart/templates/_helpers.tpl | 7 +++++++ chart/templates/service.yaml | 3 +++ chart/values.yaml | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/chart/templates/_helpers.tpl b/chart/templates/_helpers.tpl index 05e5125c..49215fbc 100644 --- a/chart/templates/_helpers.tpl +++ b/chart/templates/_helpers.tpl @@ -60,3 +60,10 @@ Create the name of the service account to use {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} + +{{/* +Return the target Kubernetes version +*/}} +{{- define "kube-httpcache.kubeVersion" -}} +{{- default .Capabilities.KubeVersion.Version .Values.kubeVersion -}} +{{- end -}} \ No newline at end of file diff --git a/chart/templates/service.yaml b/chart/templates/service.yaml index 9253ef68..e57ba1ed 100644 --- a/chart/templates/service.yaml +++ b/chart/templates/service.yaml @@ -25,3 +25,6 @@ spec: {{- end }} selector: {{- include "kube-httpcache.selectorLabels" . | nindent 4 }} + {{- if semverCompare ">=1.31-0" (include "kube-httpcache.kubeVersion" .) }} + trafficDistribution: {{ .Values.service.trafficDistribution.mode }} + {{- end }} diff --git a/chart/values.yaml b/chart/values.yaml index 688554bf..57eb90e0 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -13,6 +13,8 @@ imagePullSecrets: [] nameOverride: "" fullnameOverride: "" +kubeVersion: "" + # Enable StatefulSet (Deployment is default) useStatefulset: enabled: true @@ -187,6 +189,8 @@ service: type: ClusterIP port: 80 target: 8080 + trafficDistribution: + mode: "PreferClose" # annotations: {} ingress: