From cadfe14abeaa97555efec37a8524b583469e2b90 Mon Sep 17 00:00:00 2001 From: Pranshu Mahajan <56812953+pranshu-m@users.noreply.github.com> Date: Sat, 6 Sep 2025 01:11:51 +1000 Subject: [PATCH] =?UTF-8?q?=E2=9A=99=EF=B8=8F=20fix:=20Dynamic=20HPA=20API?= =?UTF-8?q?=20Version=20Selection=20for=20K8s=20Compatibility=20(#9320)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Pranshu Mahajan --- helm/librechat/templates/_helpers.tpl | 13 +++++++++++++ helm/librechat/templates/hpa.yaml | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/helm/librechat/templates/_helpers.tpl b/helm/librechat/templates/_helpers.tpl index 6d0476e89..4c242d958 100755 --- a/helm/librechat/templates/_helpers.tpl +++ b/helm/librechat/templates/_helpers.tpl @@ -63,3 +63,16 @@ Create the name of the service account to use {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} + +{{/* +Define apiVersion of HorizontalPodAutoscaler +*/}} +{{- define "librechat.hpa.apiVersion" -}} +{{- if .Capabilities.APIVersions.Has "autoscaling/v2" -}} +{{- print "autoscaling/v2" -}} +{{- else if .Capabilities.APIVersions.Has "autoscaling/v2beta2" -}} +{{- print "autoscaling/v2beta2" -}} +{{- else -}} +{{- print "autoscaling/v2beta1" -}} +{{- end -}} +{{- end -}} diff --git a/helm/librechat/templates/hpa.yaml b/helm/librechat/templates/hpa.yaml index b01936cdc..aa990fb66 100755 --- a/helm/librechat/templates/hpa.yaml +++ b/helm/librechat/templates/hpa.yaml @@ -1,5 +1,5 @@ {{- if .Values.autoscaling.enabled }} -apiVersion: autoscaling/v2beta1 +apiVersion: {{ include "librechat.hpa.apiVersion" $ }} kind: HorizontalPodAutoscaler metadata: name: {{ include "librechat.fullname" $ }}