{{- if and .Values.enabled .Values.autoscaling.enabled }} apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: {{ include "temporal-worker.fullname" . }} namespace: {{ include "temporal-worker.namespace" . }} labels: {{- include "temporal-worker.labels" . | nindent 4 }} app.kubernetes.io/component: temporal-worker spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: {{ include "temporal-worker.fullname" . }} minReplicas: {{ .Values.autoscaling.minReplicas }} maxReplicas: {{ .Values.autoscaling.maxReplicas }} metrics: {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} - type: Resource resource: name: cpu target: type: Utilization averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} {{- end }} {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} - type: Resource resource: name: memory target: type: Utilization averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} {{- end }} {{- with .Values.autoscaling.customMetrics }} {{- toYaml . | nindent 4 }} {{- end }} behavior: scaleDown: stabilizationWindowSeconds: {{ .Values.autoscaling.behavior.scaleDown.stabilizationWindowSeconds | default 300 }} policies: {{- range .Values.autoscaling.behavior.scaleDown.policies }} - type: {{ .type }} value: {{ .value }} periodSeconds: {{ .periodSeconds }} {{- end }} selectPolicy: Min scaleUp: stabilizationWindowSeconds: {{ .Values.autoscaling.behavior.scaleUp.stabilizationWindowSeconds | default 60 }} policies: {{- range .Values.autoscaling.behavior.scaleUp.policies }} - type: {{ .type }} value: {{ .value }} periodSeconds: {{ .periodSeconds }} {{- end }} selectPolicy: Max {{- end }}