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.read.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.readFullname" . }} |
| 12 | labels: |
| 13 | {{- include "loki.readLabels" . | nindent 4 }} |
| 14 | spec: |
| 15 | scaleTargetRef: |
| 16 | apiVersion: apps/v1 |
| 17 | {{- if and $isSimpleScalable (not .Values.read.legacyReadTarget ) }} |
| 18 | kind: Deployment |
| 19 | name: {{ include "loki.readFullname" . }} |
| 20 | {{- else }} |
| 21 | kind: StatefulSet |
| 22 | name: {{ include "loki.readFullname" . }} |
| 23 | {{- end }} |
| 24 | minReplicas: {{ .Values.read.autoscaling.minReplicas }} |
| 25 | maxReplicas: {{ .Values.read.autoscaling.maxReplicas }} |
| 26 | {{- with .Values.read.autoscaling.behavior }} |
| 27 | behavior: |
| 28 | {{- toYaml . | nindent 4 }} |
| 29 | {{- end }} |
| 30 | metrics: |
| 31 | {{- with .Values.read.autoscaling.targetMemoryUtilizationPercentage }} |
| 32 | - type: Resource |
| 33 | resource: |
| 34 | name: memory |
| 35 | {{- if $autoscalingv2 }} |
| 36 | target: |
| 37 | type: Utilization |
| 38 | averageUtilization: {{ . }} |
| 39 | {{- else }} |
| 40 | targetAverageUtilization: {{ . }} |
| 41 | {{- end }} |
| 42 | {{- end }} |
| 43 | {{- with .Values.read.autoscaling.targetCPUUtilizationPercentage }} |
| 44 | - type: Resource |
| 45 | resource: |
| 46 | name: cpu |
| 47 | {{- if $autoscalingv2 }} |
| 48 | target: |
| 49 | type: Utilization |
| 50 | averageUtilization: {{ . }} |
| 51 | {{- else }} |
| 52 | targetAverageUtilization: {{ . }} |
| 53 | {{- end }} |
| 54 | {{- end }} |
| 55 | {{- end }} |