Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 1 | {{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}} |
| 2 | {{- $autoscalingv2 := .Capabilities.APIVersions.Has "autoscaling/v2" -}} |
| 3 | {{- if and $isSimpleScalable ( .Values.write.autoscaling.enabled ) }} |
| 4 | {{- if $autoscalingv2 }} |
| 5 | apiVersion: autoscaling/v2 |
| 6 | {{- else }} |
| 7 | apiVersion: autoscaling/v2beta1 |
| 8 | {{- end }} |
| 9 | kind: HorizontalPodAutoscaler |
| 10 | metadata: |
| 11 | name: {{ include "loki.writeFullname" . }} |
| 12 | namespace: {{ $.Release.Namespace }} |
| 13 | labels: |
| 14 | {{- include "loki.writeLabels" . | nindent 4 }} |
| 15 | spec: |
| 16 | scaleTargetRef: |
| 17 | apiVersion: apps/v1 |
| 18 | kind: StatefulSet |
| 19 | name: {{ include "loki.writeFullname" . }} |
| 20 | minReplicas: {{ .Values.write.autoscaling.minReplicas }} |
| 21 | maxReplicas: {{ .Values.write.autoscaling.maxReplicas }} |
| 22 | {{- with .Values.write.autoscaling.behavior }} |
| 23 | behavior: |
| 24 | {{- toYaml . | nindent 4 }} |
| 25 | {{- end }} |
| 26 | metrics: |
| 27 | {{- with .Values.write.autoscaling.targetMemoryUtilizationPercentage }} |
| 28 | - type: Resource |
| 29 | resource: |
| 30 | name: memory |
| 31 | {{- if $autoscalingv2 }} |
| 32 | target: |
| 33 | type: Utilization |
| 34 | averageUtilization: {{ . }} |
| 35 | {{- else }} |
| 36 | targetAverageUtilization: {{ . }} |
| 37 | {{- end }} |
| 38 | {{- end }} |
| 39 | {{- with .Values.write.autoscaling.targetCPUUtilizationPercentage }} |
| 40 | - type: Resource |
| 41 | resource: |
| 42 | name: cpu |
| 43 | {{- if $autoscalingv2 }} |
| 44 | target: |
| 45 | type: Utilization |
| 46 | averageUtilization: {{ . }} |
| 47 | {{- else }} |
| 48 | targetAverageUtilization: {{ . }} |
| 49 | {{- end }} |
| 50 | {{- end }} |
| 51 | {{- end }} |