Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 1 | {{- $autoscalingv2 := .Capabilities.APIVersions.Has "autoscaling/v2" -}} |
| 2 | {{- if .Values.gateway.autoscaling.enabled }} |
| 3 | {{- if $autoscalingv2 }} |
| 4 | apiVersion: autoscaling/v2 |
| 5 | {{- else }} |
| 6 | apiVersion: autoscaling/v2beta1 |
| 7 | {{- end }} |
| 8 | kind: HorizontalPodAutoscaler |
| 9 | metadata: |
| 10 | name: {{ include "loki.gatewayFullname" . }} |
Giovanni Tirloni | 52306ad | 2024-04-12 15:35:05 -0300 | [diff] [blame] | 11 | namespace: {{ $.Release.Namespace }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 12 | labels: |
| 13 | {{- include "loki.gatewayLabels" . | nindent 4 }} |
| 14 | spec: |
| 15 | scaleTargetRef: |
| 16 | apiVersion: apps/v1 |
| 17 | kind: Deployment |
| 18 | name: {{ include "loki.gatewayFullname" . }} |
| 19 | minReplicas: {{ .Values.gateway.autoscaling.minReplicas }} |
| 20 | maxReplicas: {{ .Values.gateway.autoscaling.maxReplicas }} |
Giovanni Tirloni | 52306ad | 2024-04-12 15:35:05 -0300 | [diff] [blame] | 21 | {{- with .Values.gateway.autoscaling.behavior }} |
| 22 | behavior: |
| 23 | {{- toYaml . | nindent 4 }} |
| 24 | {{- end }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 25 | metrics: |
| 26 | {{- with .Values.gateway.autoscaling.targetMemoryUtilizationPercentage }} |
| 27 | - type: Resource |
| 28 | resource: |
| 29 | name: memory |
| 30 | {{- if $autoscalingv2 }} |
| 31 | target: |
| 32 | type: Utilization |
| 33 | averageUtilization: {{ . }} |
| 34 | {{- else }} |
| 35 | targetAverageUtilization: {{ . }} |
| 36 | {{- end }} |
| 37 | {{- end }} |
| 38 | {{- with .Values.gateway.autoscaling.targetCPUUtilizationPercentage }} |
| 39 | - type: Resource |
| 40 | resource: |
| 41 | name: cpu |
| 42 | {{- if $autoscalingv2 }} |
| 43 | target: |
| 44 | type: Utilization |
| 45 | averageUtilization: {{ . }} |
| 46 | {{- else }} |
| 47 | targetAverageUtilization: {{ . }} |
| 48 | {{- end }} |
| 49 | {{- end }} |
| 50 | {{- end }} |