{{- if and .Values.autoscaling.enabled (or (eq .Values.mode "deployment") (eq .Values.mode "statefulset")) }} apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: {{ include "opentelemetry-collector.fullname" . }} namespace: {{ template "opentelemetry-collector.namespace" . }} labels: {{- include "opentelemetry-collector.labels" . | nindent 4 }} spec: scaleTargetRef: apiVersion: apps/v1 kind: {{ include "opentelemetry-collector.hpaKind" . }} name: {{ include "opentelemetry-collector.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.targetMemoryUtilizationPercentage }} - type: Resource resource: name: memory target: type: Utilization averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} {{- end }} {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} - type: Resource resource: name: cpu target: type: Utilization averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} {{- end }} {{- end }}