| 1 | {{- if .Values.autoscaling.enabled }} |
| 2 | apiVersion: autoscaling/v2 |
| 3 | kind: HorizontalPodAutoscaler |
| 4 | metadata: |
| 5 | name: "{{ .Release.Name }}-hpa" |
| 6 | namespace: {{ .Release.Namespace }} |
| 7 | spec: |
| 8 | scaleTargetRef: |
| 9 | apiVersion: apps/v1 |
| 10 | kind: Deployment |
| 11 | name: {{ include "chart.deployment-name" . | quote }} |
| 12 | minReplicas: {{ .Values.autoscaling.minReplicas }} |
| 13 | maxReplicas: {{ .Values.autoscaling.maxReplicas }} |
| 14 | metrics: |
| 15 | {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} |
| 16 | - type: Resource |
| 17 | resource: |
| 18 | name: cpu |
| 19 | target: |
| 20 | type: Utilization |
| 21 | averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} |
| 22 | {{- end }} |
| 23 | {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} |
| 24 | - type: Resource |
| 25 | resource: |
| 26 | name: memory |
| 27 | target: |
| 28 | type: Utilization |
| 29 | averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} |
| 30 | {{- end }} |
| 31 | {{- end }} |