title: Azure Kubernetes - replica vs HPA?
body: <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>