Difficulty: Beginner
Estimated Time: 60 minutes

Vitess is a database solution for deploying, scaling and managing large clusters of MySQL instances. It’s architected to run as effectively in a public or private cloud architecture as it does on dedicated hardware. It combines and extends many important MySQL features with the scalability of a NoSQL database. In this scenario you will learn how to:

  • Install the pre-requisites
  • Run vitess on kubernetes using vitess operator
  • Deploy a standalone mysql deployment, load schema and data into the clusters
  • Split the data in vertical sharding
  • Split the data in horizontal sharding

Congratulations. You have successfully:

  • Ran vitess on kubernetes
  • Deployed a standalone mysql deployment, loaded schema and data into the clusters
  • Created the vitess environment, and split data in vertical sharding

Keep learning more about Vitess in this link.

Run Vitess on Kubernetes

Step 1 of 5

Step 1 - Deploy Vitess


Vitess has been downloaded in /root/vitess directory. Let's start installing some of the pre-requisites to this scenario:


Start minikube with the following command: minikube start --extra-config=apiserver.service-node-port-range=1024-65535 --cpus=4 --memory=5000 --wait=false


Initialize helm helm init


Configure tiller with the following command. This is necessary to avoid the error Error: no available release name found when you install etcd-operator. See this link for more information.

kubectl create serviceaccount --namespace kube-system tiller
kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}'


Install etcd-operator via helm helm install stable/etcd-operator


We will use an example helm chart to start a single keyspace cluster

Change to the helm example directory:

cd /root/vitess/examples/helm/

In this directory, you will see a group of yaml files. The first digit of each file name indicates the phase of example. The next two digits indicate the order in which to execute them. For example, 101_initial_cluster.yaml is the first file of the first phase. We shall execute that now:

helm install ../../helm/vitess -f 101_initial_cluster.yaml

Verify cluster

Once successful, let's analyze the resources that this helm chart has installed Run the following command:

kubectl get pods,jobs

You should see something similar to the following state:

$ kubectl get pods,jobs
NAME                                                                  READY   STATUS     RESTARTS   AGE
pod/commerce-apply-schema-initial-4hgvz                               0/1     Completed   0          3m26s
pod/commerce-apply-vschema-initial-scdkx                              0/1     Completed   0          3m26s
pod/etcd-global-bgdhmcld8r                                            1/1     Running     0          3m26s
pod/etcd-zone1-976n4gc22v                                             1/1     Running     0          3m26s
pod/kindled-penguin-etcd-operator-etcd-backup-operator-784d7dcvm8bj   1/1     Running     0          5m31s
pod/kindled-penguin-etcd-operator-etcd-operator-768fff586f-qqnnf      1/1     Running     0          5m31s
pod/kindled-penguin-etcd-operator-etcd-restore-operator-5c7c4cx4x66   1/1     Running     0          5m31s
pod/vtctld-9b7d47bbc-zpr27                                            1/1     Running     2          3m26s
pod/vtgate-zone1-67ddd6c959-6hfgg                                     1/1     Running     2          3m26s
pod/zone1-commerce-0-init-shard-master-v52js                          0/1     Completed   0          3m26s
pod/zone1-commerce-0-rdonly-0                                         6/6     Running     0          3m26s
pod/zone1-commerce-0-replica-0                                        6/6     Running     0          3m26s
pod/zone1-commerce-0-replica-1                                        6/6     Running     0          3m26s

NAME                                           COMPLETIONS   DURATION   AGE
job.batch/commerce-apply-schema-initial        1/1           94s        3m26s
job.batch/commerce-apply-vschema-initial       1/1           86s        3m26s
job.batch/zone1-commerce-0-init-shard-master   1/1           86s        3m26s

When you see the pods are in state Running, test connecting to the cluster using the following command:


Notice that when you connect to the cluster, you are "speaking" MySQL but you are accessing through Vitess:

$ kmysql.sh
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.10-Vitess Percona Server (GPL), Release 23, Revision 500fcf5

Just for the effect to test the cluster, list the available tables, using this command: show tables;

After that, exit from the MySQL client exit