0

The documentation of VPA states that HPA and VPA should not be used together. It can only be used to gethere when you want scaling on custom metrics.

I have scaling enabled on CPU.

My question is can I have HPA enabled for some deployment (lets say A) and VPA enabled for some deployment (lets say B). Or will this also leed to errors.

pratikvasa
  • 1,897
  • 20
  • 24

1 Answers1

1

Using them both at the same time is not suggested because if they both detect that the memory is need they might want to try to resolve the same problems at the same time which will lead to wrongly allocated resources.

This is not something that can be specified at the application deployment level but you can specify which deployment should HPA and VPA scale using targetRef

So for the deployment with app1 you can specify VPA:

apiVersion: autoscaling.k8s.io/v1beta2
kind: VerticalPodAutoscaler
metadata:
  name: app1-vpa
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: app1

And for the app2 you can specify to use HPA:

apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
  name: app2-hpa 
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: app2

If need to use HPA and VPA together on the same deployments, you just have to make sure that the will based they behavior on different metrics. This way you prevent them by being scaled by the same event. To summarize VPA and HPA can be used together if he HPA config won`t use CPU or Memory to determine its targets as stated in the documentation:

"Vertical Pod Autoscaler should not be used with the Horizontal Pod Autoscaler (HPA) on CPU or memory at this moment"

acid_fuji
  • 6,287
  • 7
  • 22
  • So thats where I am in doubt. If I have a service that is to be scaled horizontally based on CPU. And there is another service that is to be scaled vertically by increasing the CPU, how will they conflict. It may be that they both would need resources but the total requirement of resources would be independant. – pratikvasa Jun 08 '20 at 08:49
  • @pratikvasa I have edited my answer after your comment since I thought you want to specify scalers at the app deployment level. Hope that helps. – acid_fuji Jun 08 '20 at 09:48