Files
devops-infra-helm-charts-gcp/helm-templates/deepgram-onprem/templates/engine/engine.hpa.yaml
T
2026-08-26 03:39:42 +05:30

74 lines
3.1 KiB
YAML

{{- if .Values.scaling.auto.enabled -}}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ .Values.engine.namePrefix }}-hpa
labels: &labels
{{ include "deepgram-self-hosted.labels" . | indent 4}}
{{- range $key, $val := .Values.engine.additionalLabels }}
{{ $key }}: {{ $val | quote }}
{{- end}}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ .Values.engine.namePrefix }}
minReplicas: {{ .Values.scaling.auto.engine.minReplicas }}
maxReplicas: {{ .Values.scaling.auto.engine.maxReplicas }}
metrics:
{{- $sttBatchScaling := .Values.scaling.auto.engine.metrics.speechToText.batch.requestsPerPod }}
{{- $sttStreamingScaling := .Values.scaling.auto.engine.metrics.speechToText.streaming.requestsPerPod }}
{{- $ttsBatchScaling := .Values.scaling.auto.engine.metrics.textToSpeech.batch.requestsPerPod }}
{{- $requestCapacityScaling := .Values.scaling.auto.engine.metrics.requestCapacityRatio }}
{{- $customScaling := .Values.scaling.auto.engine.metrics.custom }}
{{- if and (not $sttBatchScaling) (not $sttStreamingScaling) (not $ttsBatchScaling) (not $requestCapacityScaling) (not $customScaling) }}
{{- fail "Error: When autoscaling is enabled, at least one scaling metric in scaling.auto.engine.metrics must be defined." }}
{{- end }}
{{- if .Values.scaling.auto.engine.metrics.speechToText.batch.requestsPerPod }}
- type: External
external:
metric:
name: engine_active_requests_stt_batch
target:
type: Value
value: {{ .Values.scaling.auto.engine.metrics.speechToText.batch.requestsPerPod }}
{{- end }}
{{- if .Values.scaling.auto.engine.metrics.speechToText.streaming.requestsPerPod }}
- type: External
external:
metric:
name: engine_active_requests_stt_streaming
target:
type: Value
value: {{ .Values.scaling.auto.engine.metrics.speechToText.streaming.requestsPerPod }}
{{- end }}
{{- if .Values.scaling.auto.engine.metrics.textToSpeech.batch.requestsPerPod }}
- type: External
external:
metric:
name: engine_active_requests_tts_batch
target:
type: Value
value: {{ .Values.scaling.auto.engine.metrics.textToSpeech.batch.requestsPerPod }}
{{- end }}
{{- if .Values.scaling.auto.engine.metrics.requestCapacityRatio }}
{{- if not .Values.engine.concurrencyLimit.activeRequests }}
{{- fail "Error: engine.concurrencyLimit.activeRequests must be set to autoscale using requestCapacityRatio." }}
{{- end }}
- type: External
external:
metric:
name: engine_requests_active_to_max_ratio
target:
type: Value
value: {{ .Values.scaling.auto.engine.metrics.requestCapacityRatio }}
{{- end }}
{{- if .Values.scaling.auto.engine.metrics.custom }}
{{- toYaml .Values.scaling.auto.engine.metrics.custom | nindent 4 }}
{{- end }}
behavior:
{{- toYaml .Values.scaling.auto.engine.behavior | nindent 4 }}
{{- end -}}