<p>When I am applying helm deployment yaml file in below format (with range) deployment works fine but it applies HorizontalPodAutoscaler only for one of the deployment.</p>
<pre><code>{{- range .Values.services }}
{{ if .enabled }}
apiVersion: apps/v1
kind: Deployment
{{- range .Values.services }}
Metadata:
.
.
.
spec:
.
.
.
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
  name: mlservice-{{.name}}-v{{.version}}
  namespace: {{$.Values.namespace }}
spec:
  scaleTargetRef:
  apiVersion: apps/v1
  kind: Deployment
  name: mlservice-{{.name}}-v{{.version}}
minReplicas: {{ $.Values.minReplicas }}
maxReplicas: {{ $.Values.maxReplicas }}
targetCPUUtilizationPercentage: {{ $.Values.targetCPUUtilizationPercentage }}
{{ end }}
{{- end }}
</code></pre>
<p>github action logs I see like :</p>
<p>client.go:239: [debug] Created a new HorizontalPodAutoscaler called &quot;<strong>service-v1</strong>&quot; in namespace</p>
<p>but I don't see anything like
Created a new HorizontalPodAutoscaler called &quot;<strong>service-v2</strong>&quot;</p>
<p>No clue why , I am using aws EKS and complete workload works fine. except doing &quot;kubectl get hpa&quot; returns only one service. Before I had only one service and auto scaling and all workload used to work fine.</p>

archit
<p>Fixed this HPA issue :
need to add '---' at end of HorizontalPodAutoscaler section in deployment.yaml this is required because it is inside loop and k8s needs to understand that iteration is over.</p>
