Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 1 | {{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}} |
| 2 | {{- if and $isDistributed .Values.distributor.autoscaling.enabled }} |
| 3 | {{- $apiVersion := include "loki.hpa.apiVersion" . -}} |
| 4 | apiVersion: {{ $apiVersion }} |
| 5 | kind: HorizontalPodAutoscaler |
| 6 | metadata: |
| 7 | name: {{ include "loki.distributorFullname" . }} |
| 8 | labels: |
| 9 | {{- include "loki.distributorLabels" . | nindent 4 }} |
| 10 | spec: |
| 11 | scaleTargetRef: |
| 12 | apiVersion: apps/v1 |
| 13 | kind: Deployment |
| 14 | name: {{ include "loki.distributorFullname" . }} |
| 15 | minReplicas: {{ .Values.distributor.autoscaling.minReplicas }} |
| 16 | maxReplicas: {{ .Values.distributor.autoscaling.maxReplicas }} |
| 17 | metrics: |
| 18 | {{- with .Values.distributor.autoscaling.targetMemoryUtilizationPercentage }} |
| 19 | - type: Resource |
| 20 | resource: |
| 21 | name: memory |
| 22 | {{- if (eq $apiVersion "autoscaling/v2") }} |
| 23 | target: |
| 24 | type: Utilization |
| 25 | averageUtilization: {{ . }} |
| 26 | {{- else }} |
| 27 | targetAverageUtilization: {{ . }} |
| 28 | {{- end }} |
| 29 | {{- end }} |
| 30 | {{- with .Values.distributor.autoscaling.targetCPUUtilizationPercentage }} |
| 31 | - type: Resource |
| 32 | resource: |
| 33 | name: cpu |
| 34 | {{- if (eq $apiVersion "autoscaling/v2") }} |
| 35 | target: |
| 36 | type: Utilization |
| 37 | averageUtilization: {{ . }} |
| 38 | {{- else }} |
| 39 | targetAverageUtilization: {{ . }} |
| 40 | {{- end }} |
| 41 | {{- end }} |
| 42 | {{- with .Values.distributor.autoscaling.customMetrics }} |
| 43 | {{- toYaml . | nindent 4 }} |
| 44 | {{- end }} |
| 45 | {{- if .Values.distributor.autoscaling.behavior.enabled }} |
| 46 | behavior: |
| 47 | {{- with .Values.distributor.autoscaling.behavior.scaleDown }} |
| 48 | scaleDown: {{ toYaml . | nindent 6 }} |
| 49 | {{- end }} |
| 50 | {{- with .Values.distributor.autoscaling.behavior.scaleUp }} |
| 51 | scaleUp: {{ toYaml . | nindent 6 }} |
| 52 | {{- end }} |
| 53 | {{- end }} |
| 54 | {{- end }} |