<p>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.</p>

<p>I have scaling enabled on CPU.</p>

<p>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.</p>

pratikvasa
<p>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. </p>

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

<p>So for the deployment with <code>app1</code> you can specify <code>VPA</code>: </p>

<pre class="lang-yaml prettyprint-override"><code>apiVersion: autoscaling.k8s.io/v1beta2
kind: VerticalPodAutoscaler
metadata:
  name: app1-vpa
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: app1
</code></pre>

<p>And for the <code>app2</code> you can specify to use <code>HPA</code>: </p>

<pre class="lang-yaml prettyprint-override"><code>apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
  name: app2-hpa 
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: app2
</code></pre>

<p>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: </p>

<blockquote>
  <p>"Vertical Pod Autoscaler <strong>should not be used with the</strong>  <strong>Horizontal
  Pod Autoscaler</strong>  <strong>(HPA) on CPU or memory</strong> at this moment"</p>
</blockquote>
