<p>I want to apply <code>VPA</code> <strong>vertical pod auto scaling</strong> for database pods. Can we use <code>VPA</code> for database auto scaling (Vertical) as <code>VPA</code> requires at least 2 replicas (ref : <a href="https://github.com/kubernetes/autoscaler/issues/1665#issuecomment-464679271" rel="nofollow noreferrer">https://github.com/kubernetes/autoscaler/issues/1665#issuecomment-464679271</a>) as it delete pods when set criteria is reached. So pods are deleted hence also data.</p>
<p>What is good practice for using <code>VPA</code> with database pods?</p>

Developer Desk
<p>As I understand it, the real question is how to run a stateful workload with multiple replicas.</p>
<p>Use <a href="https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/" rel="nofollow noreferrer">StatefulSets</a> to configure <strong>n</strong> replicas for a database. StatefulSet pods have stable names which are preserved across pod restarts (and reincarnations). Combined with <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims" rel="nofollow noreferrer">PersistentVolumeClaim</a> templates (accepted with StatefulSet spec) and <a href="https://kubernetes.io/docs/concepts/services-networking/service/#headless-services" rel="nofollow noreferrer">headless services</a>, it is capable of retaining same volumes and network FQDN across reincarnations.</p>
<p>Take a look at Helm charts for various databases, e.g. <a href="https://github.com/helm/charts/tree/master/stable/mysql" rel="nofollow noreferrer">MySQL chart</a>, for useful insights.</p>
<p>On a side note, it might be worthwhile to consider using an operator for the database application you're using. Operators for most applications can be found on <a href="https://operatorhub.io" rel="nofollow noreferrer">https://operatorhub.io</a>.</p>
