{{- if .Values.autoscaling.enabled }} {{- $apiVersions := .Capabilities.APIVersions -}} {{- if $apiVersions.Has "autoscaling/v2" }} apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: {{ template "docker-registry.fullname" . }} labels: app: {{ template "docker-registry.name" . }} chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} release: {{ .Release.Name }} heritage: {{ .Release.Service }} spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: {{ template "docker-registry.fullname" . }} minReplicas: {{ .Values.autoscaling.minReplicas }} maxReplicas: {{ .Values.autoscaling.maxReplicas }} metrics: {{- with .Values.autoscaling.targetCPUUtilizationPercentage }} - type: Resource resource: name: cpu target: type: Utilization averageUtilization: {{ . }} {{- end }} {{- with .Values.autoscaling.targetMemoryUtilizationPercentage }} - type: Resource resource: name: memory target: type: Utilization averageUtilization: {{ . }} {{- end }} {{- with .Values.autoscaling.behavior }} behavior: {{- toYaml . | nindent 4 }} {{- end }} {{- end }} {{- end }}