{{- if .Values.autoscaling.enabled }} apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: {{ include "litellm.fullname" . }} labels: {{- include "litellm.labels" . | nindent 4 }} spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: {{ include "litellm.fullname" . }} minReplicas: {{ .Values.autoscaling.minReplicas }} maxReplicas: {{ .Values.autoscaling.maxReplicas }} {{- if .Values.autoscaling.behavior }} behavior: {{- toYaml .Values.autoscaling.behavior | nindent 4 }} {{- end }} metrics: {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} {{- if and .Values.collector.enabled .Values.collector.scaleOnProxyContainerCpu }} - type: ContainerResource containerResource: name: cpu container: {{ include "litellm.name" . }} target: type: Utilization averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} {{- else }} - type: Resource resource: name: cpu target: type: Utilization averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} {{- end }} {{- end }} {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} - type: Resource resource: name: memory target: type: Utilization averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} {{- end }} {{- with .Values.autoscaling.targetRequestsPerSecond }} - type: Pods pods: metric: name: litellm_requests_per_second target: type: AverageValue averageValue: {{ toJson . | trimAll "\"" | quote }} {{- end }} {{- with .Values.autoscaling.targetTokensPerSecond }} - type: Pods pods: metric: name: litellm_tokens_per_second target: type: AverageValue averageValue: {{ toJson . | trimAll "\"" | quote }} {{- end }} {{- end }}