Home > Blockchain >  Kubernetes - when to use HorizontalPodAutoscaler resource type?
Kubernetes - when to use HorizontalPodAutoscaler resource type?

Time:10-03

As mentioned in this answer: allow for easy updating of a Replica Set as well as the ability to roll back to a previous deployment.

So, kind: Deployment scales replicasets, which scales Pods, supports zero-downtime updates by creating and destroying replicasets


What is the purpose of HorizontalPodAutoscaler resource type?

apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
  name: xyz
spec:
  maxReplicas: 4
  minReplicas: 2
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: xyz
  targetCPUUtilizationPercentage: 70

CodePudding user response:

As you write, with a Deployment it is easy to manually scale an app horizontally, by changing the numer of replicas.

By using a HorizontalPodAutoscaler, you can automate the horizontal scaling by e.g. configuring some metric thresholds, therefore the name autoscaler.

  • Related