<p>What is the difference between replicas and HPA?</p>
<p>For sample, below deployment is configured with 3 replicas</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello
spec:
  **replicas: 3**
</code></pre>
<p>and the below HPA with 2-20 replicas</p>
<pre><code>apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
  name: hello
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: hello
  **minReplicas: 2
  maxReplicas: 20
metrics:
  - type: Resource
    resource:
      name: cpu
      targetAverageUtilization: 80**
</code></pre>
<p>does it mean that the above HPA will control the overall number of replicas irrespective of what is defined in the &quot;deployment.yaml&quot;? When HPA scales up would it add one more &quot;deployment&quot; replica or three more &quot;deployment&quot; replicas?</p>

One Developer
<p>Yes the answer is, based on the observations those I had with AKS.</p>
<p>The deployment.yaml, asks for desired number of replicas, and hpa carries the variation around this based on metrics configured.</p>
<p>The desired state or replicas in deployment object ( when you do kubectl get deploy ), will give the current replicas as well as desired replicas always and you can see a variation there with the load.</p>
<p>So it will start with 3 instances and then it will try to keep min replicas always available ( hence the min-replicas in hpa and replicas in deployment file are kept same ), and then based on load computation against the provided metrics, it will scale up or down to min or max defined levels.</p>
