<p>I have deployed a HPA the configuration showed at the bottom. It scales up when either CPU or Memory usage is above 75%. The initial replicas count is 1 and the max is 3. But I can see the pod count was scaled up to 3 1 few minutes after I deploy the HPA.</p>
<p>The current usage of CPU/Memory is shown below. You can see it is quit low compare the <code>requested</code> resources which is 2 CPU and 8GB memory. I don't understand why it scales. Did I make any mistake on the configuration?</p>
<pre><code>$ kubectl top pod transform-67df4445c5-6qpdd
W0818 16:04:43.199730   63930 top_pod.go:140] Using json format to get metrics. Next release will switch to protocol-buffers, switch early by passing --use-protocol-buffers flag
NAME                         CPU(cores)   MEMORY(bytes)
transform-67df4445c5-6qpdd   250m         495Mi
</code></pre>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: transform
  namespace: default
spec:
  replicas: 1

  selector:
    matchLabels:
      name: transform
  template:
    metadata:
      labels:
        name: transform
    spec:
      containers:
        - name: transform
          image: zhaoyi0113/es-kinesis-firehose-transform
          resources:
            requests:
              cpu: 2
              memory: 8
          ports:
            - containerPort: 8080
---
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
  name: transform
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: transform
  minReplicas: 1
  maxReplicas: 3
  metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 75
  - type: Resource
    resource:
      name: memory
      target:
        type: Utilization
        averageUtilization: 75
</code></pre>

Joey Yi Zhao
<p>You have mentioned the resource <strong>without unit</strong> : <a href="https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#resource-units-in-kubernetes" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#resource-units-in-kubernetes</a></p>
<pre><code>resources:
            requests:
              cpu: 2
              memory: 8
</code></pre>
<p>for memory, it could be <strong>8</strong> Mi and usage is <strong>450</strong>Mi so it's above. That also could be a reason. You have not mentioned the limit for resource so it always best practice to add the limit also in resource.</p>
<p>So that HPA can calculate the % based on request and limit you set to resource section.</p>
<p>You can also check the</p>
<pre><code>kubectl get hpa
</code></pre>
<p>or</p>
<pre><code>kubectl describe hpa &lt;name&gt;
</code></pre>
<p>to check the usage % and event details.</p>
<p>here is nice best practice article from google : <a href="https://cloud.google.com/blog/products/containers-kubernetes/kubernetes-best-practices-resource-requests-and-limits" rel="nofollow noreferrer">https://cloud.google.com/blog/products/containers-kubernetes/kubernetes-best-practices-resource-requests-and-limits</a></p>
