1.

If you have multiple containers in a Deployment file, does use the HorizontalPodAutoscaler scale all of the containers?

Answer»

Yes, it would scale all of them, INTERNALLY the deployment creates a replica set (which does the SCALING), and then a set number of pods are made by that replica set. the pod is what actually holds both of those containers. and if you want to scale them independently they should be separate pods (and therefore replica sets, deployments, etc).so for HPA to work You need to SPECIFY min and MAX replicas  and the threshold what percentage of cpu and memory you want your pods to autoscale..without having the manually run kubectl autoscale deployment ,you can use the below yaml file to do the same 

  • apiVersion: autoscaling/v1
  • kind: HorizontalPodAutoscaler
  • metadata:
  • annotations:
  • name: app
  • spec:
  • maxReplicas: 15
  • minReplicas: 10
  • scaleTargetRef:
  • apiVersion: autoscaling/v1
  • kind: Deployment
  • name: app targetCPUUtilizationPercentage: 70


Discussion

No Comment Found

Related InterviewSolutions