blob: ff673c2fcf3f2772352b054d6b5f56ddc09d6e8a [file] [log] [blame]
Oleksandr Kozachenkob0093492023-09-06 21:43:47 +02001{{- /*
Mohammed Naser7d1623e2024-06-17 09:12:39 -04002Copyright Broadcom, Inc. All Rights Reserved.
Oleksandr Kozachenkob0093492023-09-06 21:43:47 +02003SPDX-License-Identifier: APACHE-2.0
4*/}}
5
6{{- if .Values.autoscaling.enabled }}
7apiVersion: {{ include "common.capabilities.hpa.apiVersion" ( dict "context" $ ) }}
8kind: HorizontalPodAutoscaler
9metadata:
10 name: {{ template "common.names.fullname" . }}
11 namespace: {{ include "common.names.namespace" . | quote }}
Mohammed Naser65cda132024-05-02 14:34:08 -040012 labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
Oleksandr Kozachenkob0093492023-09-06 21:43:47 +020013 app.kubernetes.io/component: keycloak
Oleksandr Kozachenkob0093492023-09-06 21:43:47 +020014 {{- if .Values.commonAnnotations }}
15 annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
16 {{- end }}
17spec:
18 scaleTargetRef:
19 apiVersion: {{ include "common.capabilities.statefulset.apiVersion" . }}
20 kind: StatefulSet
21 name: {{ template "common.names.fullname" . }}
22 minReplicas: {{ .Values.autoscaling.minReplicas }}
23 maxReplicas: {{ .Values.autoscaling.maxReplicas }}
24 metrics:
25 {{- if .Values.autoscaling.targetCPU }}
26 - type: Resource
27 resource:
28 name: cpu
29 {{- if semverCompare "<1.23-0" (include "common.capabilities.kubeVersion" .) }}
30 targetAverageUtilization: {{ .Values.autoscaling.targetCPU }}
31 {{- else }}
32 target:
33 type: Utilization
34 averageUtilization: {{ .Values.autoscaling.targetCPU }}
35 {{- end }}
36 {{- end }}
37 {{- if .Values.autoscaling.targetMemory }}
38 - type: Resource
39 resource:
40 name: memory
41 {{- if semverCompare "<1.23-0" (include "common.capabilities.kubeVersion" .) }}
42 targetAverageUtilization: {{ .Values.autoscaling.targetMemory }}
43 {{- else }}
44 target:
45 type: Utilization
46 averageUtilization: {{ .Values.autoscaling.targetMemory }}
47 {{- end }}
48 {{- end }}
Mohammed Naser7d1623e2024-06-17 09:12:39 -040049 {{- if or .Values.autoscaling.behavior.scaleDown.policies .Values.autoscaling.behavior.scaleUp.policies }}
50 behavior:
51 {{- if .Values.autoscaling.behavior.scaleDown.policies }}
52 scaleDown:
53 stabilizationWindowSeconds: {{ .Values.autoscaling.behavior.scaleDown.stabilizationWindowSeconds }}
54 selectPolicy: {{ .Values.autoscaling.behavior.scaleDown.selectPolicy }}
55 policies:
56 {{- toYaml .Values.autoscaling.behavior.scaleDown.policies | nindent 8 }}
57 {{- end }}
58 {{- if .Values.autoscaling.behavior.scaleUp.policies }}
59 scaleUp:
60 stabilizationWindowSeconds: {{ .Values.autoscaling.behavior.scaleUp.stabilizationWindowSeconds }}
61 selectPolicy: {{ .Values.autoscaling.behavior.scaleUp.selectPolicy }}
62 policies:
63 {{- toYaml .Values.autoscaling.behavior.scaleUp.policies | nindent 8 }}
64 {{- end }}
65 {{- end }}
Oleksandr Kozachenkob0093492023-09-06 21:43:47 +020066{{- end }}