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" . }} |
| 11 | labels: |
| 12 | {{- include "loki.gatewayLabels" . | nindent 4 }} |
| 13 | spec: |
| 14 | scaleTargetRef: |
| 15 | apiVersion: apps/v1 |
| 16 | kind: Deployment |
| 17 | name: {{ include "loki.gatewayFullname" . }} |
| 18 | minReplicas: {{ .Values.gateway.autoscaling.minReplicas }} |
| 19 | maxReplicas: {{ .Values.gateway.autoscaling.maxReplicas }} |
| 20 | metrics: |
| 21 | {{- with .Values.gateway.autoscaling.targetMemoryUtilizationPercentage }} |
| 22 | - type: Resource |
| 23 | resource: |
| 24 | name: memory |
| 25 | {{- if $autoscalingv2 }} |
| 26 | target: |
| 27 | type: Utilization |
| 28 | averageUtilization: {{ . }} |
| 29 | {{- else }} |
| 30 | targetAverageUtilization: {{ . }} |
| 31 | {{- end }} |
| 32 | {{- end }} |
| 33 | {{- with .Values.gateway.autoscaling.targetCPUUtilizationPercentage }} |
| 34 | - type: Resource |
| 35 | resource: |
| 36 | name: cpu |
| 37 | {{- if $autoscalingv2 }} |
| 38 | target: |
| 39 | type: Utilization |
| 40 | averageUtilization: {{ . }} |
| 41 | {{- else }} |
| 42 | targetAverageUtilization: {{ . }} |
| 43 | {{- end }} |
| 44 | {{- end }} |
| 45 | {{- end }} |