Improve HPA (#354)

* Use `autoscaling/v2` if Kubernetes version >= 1.23

Signed-off-by: Atkins Chang <atkinschang@gmail.com>

* Disable replicas when autoscaling enabled

Signed-off-by: Atkins Chang <atkinschang@gmail.com>

---------

Signed-off-by: Atkins Chang <atkinschang@gmail.com>
This commit is contained in:
Atkins 2023-07-12 23:18:19 +08:00 committed by GitHub
parent f8ad65066e
commit b30eb6fff8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 0 deletions

View File

@ -18,7 +18,11 @@
# #
{{- if .Values.broker.autoscaling.enabled }} {{- if .Values.broker.autoscaling.enabled }}
{{- if (semverCompare "<1.23-0" .Capabilities.KubeVersion.Version) }}
apiVersion: autoscaling/v2beta2 apiVersion: autoscaling/v2beta2
{{- else }}
apiVersion: autoscaling/v2
{{- end }}
kind: HorizontalPodAutoscaler kind: HorizontalPodAutoscaler
metadata: metadata:
name: "{{ template "pulsar.fullname" . }}-{{ .Values.broker.component }}" name: "{{ template "pulsar.fullname" . }}-{{ .Values.broker.component }}"

View File

@ -28,7 +28,9 @@ metadata:
component: {{ .Values.broker.component }} component: {{ .Values.broker.component }}
spec: spec:
serviceName: "{{ template "pulsar.fullname" . }}-{{ .Values.broker.component }}" serviceName: "{{ template "pulsar.fullname" . }}-{{ .Values.broker.component }}"
{{- if not .Values.broker.autoscaling.enabled }}
replicas: {{ .Values.broker.replicaCount }} replicas: {{ .Values.broker.replicaCount }}
{{- end }}
selector: selector:
matchLabels: matchLabels:
{{- include "pulsar.matchLabels" . | nindent 6 }} {{- include "pulsar.matchLabels" . | nindent 6 }}

View File

@ -18,7 +18,11 @@
# #
{{- if .Values.proxy.autoscaling.enabled }} {{- if .Values.proxy.autoscaling.enabled }}
{{- if (semverCompare "<1.23-0" .Capabilities.KubeVersion.Version) }}
apiVersion: autoscaling/v2beta2 apiVersion: autoscaling/v2beta2
{{- else }}
apiVersion: autoscaling/v2
{{- end }}
kind: HorizontalPodAutoscaler kind: HorizontalPodAutoscaler
metadata: metadata:
name: "{{ template "pulsar.fullname" . }}-{{ .Values.proxy.component }}" name: "{{ template "pulsar.fullname" . }}-{{ .Values.proxy.component }}"

View File

@ -28,7 +28,9 @@ metadata:
component: {{ .Values.proxy.component }} component: {{ .Values.proxy.component }}
spec: spec:
serviceName: "{{ template "pulsar.fullname" . }}-{{ .Values.proxy.component }}" serviceName: "{{ template "pulsar.fullname" . }}-{{ .Values.proxy.component }}"
{{- if not .Values.proxy.autoscaling.enabled }}
replicas: {{ .Values.proxy.replicaCount }} replicas: {{ .Values.proxy.replicaCount }}
{{- end }}
selector: selector:
matchLabels: matchLabels:
{{- include "pulsar.matchLabels" . | nindent 6 }} {{- include "pulsar.matchLabels" . | nindent 6 }}