<p>I deployed my java web application in kubernetes using DEPLOYMENTS and was able to scale it and connect it to a database POD, but then I wanted to scale the database too but as you know is not possible in kubernetes and the MYSQL REPLICA not recommended for production. So I tried vitess and was able to scale my database but don't know how or where should I create my java web application DEPLOYMENTS/REPLICAS and connect them to the database through vtgate.
And is there another way of scaling mysql database through kubernetes ?</p>

<p>It's important to note that Vitess is not a transparent proxy that you can just insert between the app and MySQL at the connection level. Vitess turns a set of MySQL servers into a clustered database, and it requires you to build your app against a Vitess driver instead of the plain MySQL driver.</p>

<p>If you're already using JDBC, you shouldn't need a lot of code changes other than connection management, since there is a <a href="https://github.com/youtube/vitess/blob/master/java/example/src/main/java/com/youtube/vitess/example/VitessJDBCExample.java" rel="nofollow noreferrer">Vitess implementation of the JDBC interface</a>. However, some query constructs may not be supported yet by Vitess, so you may need to rewrite them into an equivalent form that is supported.</p>

<p>Once your app is compatible with Vitess, deploying it in Kubernetes will be the same as you did before, except you will point the app pods to <a href="https://github.com/youtube/vitess/blob/faed5ff5fc854ec3a33125318a791391faaaf638/examples/kubernetes/guestbook/main.py#L84" rel="nofollow noreferrer">connect to the VTGate service via DNS</a>.</p>

<p>As for other ways to scale MySQL in Kubernetes without Vitess, there's an important new feature entering Beta in Kubernetes 1.5 called StatefulSet that will help you scale databases like MySQL similar to the way a Deployment can scale stateless Pods. Vitess itself will also become more convenient to scale in Kubernetes by taking advantage of StatefulSet.</p>

<p>However, StatefulSet with pure MySQL will mostly only help you scale read-only traffic by increasing the number of slaves. If you need to scale write traffic, you will likely need to implement application-defined sharding. At that point, the required changes to your app will almost certainly be much more than if you modify it to support Vitess.</p>
