k3s/examples/vitess
Anthony Yeh 573dfab797 examples/vitess: Update for Vitess v2.0.0-alpha3
Also pin the images on a specific version, since breaking changes are
still possible during alpha.
2015-10-03 13:58:14 -07:00
..
README.md Add Vitess example for sharded MySQL in Kubernetes. 2015-09-25 14:50:17 -07:00
create_test_table.sql Add Vitess example for sharded MySQL in Kubernetes. 2015-09-25 14:50:17 -07:00
env.sh Add Vitess example for sharded MySQL in Kubernetes. 2015-09-25 14:50:17 -07:00
etcd-controller-template.yaml Add Vitess example for sharded MySQL in Kubernetes. 2015-09-25 14:50:17 -07:00
etcd-down.sh Add Vitess example for sharded MySQL in Kubernetes. 2015-09-25 14:50:17 -07:00
etcd-service-template.yaml Add Vitess example for sharded MySQL in Kubernetes. 2015-09-25 14:50:17 -07:00
etcd-up.sh Add Vitess example for sharded MySQL in Kubernetes. 2015-09-25 14:50:17 -07:00
guestbook-controller.yaml examples/vitess: Update for Vitess v2.0.0-alpha3 2015-10-03 13:58:14 -07:00
guestbook-down.sh Add Vitess example for sharded MySQL in Kubernetes. 2015-09-25 14:50:17 -07:00
guestbook-service.yaml Add Vitess example for sharded MySQL in Kubernetes. 2015-09-25 14:50:17 -07:00
guestbook-up.sh Add Vitess example for sharded MySQL in Kubernetes. 2015-09-25 14:50:17 -07:00
vitess-down.sh Add Vitess example for sharded MySQL in Kubernetes. 2015-09-25 14:50:17 -07:00
vitess-up.sh Add Vitess example for sharded MySQL in Kubernetes. 2015-09-25 14:50:17 -07:00
vtctld-controller.yaml examples/vitess: Update for Vitess v2.0.0-alpha3 2015-10-03 13:58:14 -07:00
vtctld-down.sh Add Vitess example for sharded MySQL in Kubernetes. 2015-09-25 14:50:17 -07:00
vtctld-service.yaml Add Vitess example for sharded MySQL in Kubernetes. 2015-09-25 14:50:17 -07:00
vtctld-up.sh Add Vitess example for sharded MySQL in Kubernetes. 2015-09-25 14:50:17 -07:00
vtgate-controller-template.yaml examples/vitess: Update for Vitess v2.0.0-alpha3 2015-10-03 13:58:14 -07:00
vtgate-down.sh Add Vitess example for sharded MySQL in Kubernetes. 2015-09-25 14:50:17 -07:00
vtgate-service.yaml Add Vitess example for sharded MySQL in Kubernetes. 2015-09-25 14:50:17 -07:00
vtgate-up.sh Add Vitess example for sharded MySQL in Kubernetes. 2015-09-25 14:50:17 -07:00
vttablet-down.sh Add Vitess example for sharded MySQL in Kubernetes. 2015-09-25 14:50:17 -07:00
vttablet-pod-template.yaml examples/vitess: Update for Vitess v2.0.0-alpha3 2015-10-03 13:58:14 -07:00
vttablet-up.sh Add Vitess example for sharded MySQL in Kubernetes. 2015-09-25 14:50:17 -07:00

README.md

WARNING WARNING WARNING WARNING WARNING

PLEASE NOTE: This document applies to the HEAD of the source tree

If you are using a released version of Kubernetes, you should refer to the docs that go with that version.

The latest 1.0.x release of this document can be found [here](http://releases.k8s.io/release-1.0/examples/vitess/README.md).

Documentation for other releases can be found at releases.k8s.io.

Vitess Example

This example shows how to run a Vitess cluster in Kubernetes. Vitess is a MySQL clustering system developed at YouTube that makes sharding transparent to the application layer. It also makes scaling MySQL within Kubernetes as simple as launching more pods.

The example brings up a database with 2 shards, and then runs a pool of sharded guestbook pods. The guestbook app was ported from the original guestbook example found elsewhere in this tree, modified to use Vitess as the backend.

For a more detailed, step-by-step explanation of this example setup, see the Vitess on Kubernetes guide.

Prerequisites

You'll need to install Go 1.4+ to build vtctlclient, the command-line admin tool for Vitess.

We also assume you have a running Kubernetes cluster with kubectl pointing to it by default. See the Getting Started guides for how to get to that point. Note that your Kubernetes cluster needs to have enough resources (CPU+RAM) to schedule all the pods. By default, this example requires a cluster-wide total of at least 6 virtual CPUs and 10GiB RAM. You can tune these requirements in the resource limits section of each YAML file.

Lastly, you need to open ports 30000 (for the Vitess admin daemon) and 80 (for the guestbook app) in your firewall. See the Services and Firewalls guide for examples of how to do that.

Start Vitess

./vitess-up.sh

This will run through the steps to bring up Vitess. At the end, you should see something like this:

****************************
* Complete!
* Use the following line to make an alias to kvtctl:
* alias kvtctl='$GOPATH/bin/vtctlclient -server 104.197.47.173:30000'
* See the vtctld UI at: http://104.197.47.173:30000
****************************

Start the Guestbook app

./guestbook-up.sh

The guestbook service is configured with type: LoadBalancer to tell Kubernetes to expose it on an external IP. It may take a minute to set up, but you should soon see the external IP show up under the internal one like this:

$ kubectl get service guestbook
NAME        LABELS    SELECTOR         IP(S)             PORT(S)
guestbook   <none>    name=guestbook   10.67.253.173     80/TCP
                                       104.197.151.132

Visit the external IP in your browser to view the guestbook. Note that in this modified guestbook, there are multiple pages to demonstrate range-based sharding in Vitess. Each page number is assigned to one of the shards using a consistent hashing scheme.

Tear down

./guestbook-down.sh
./vitess-down.sh

You may also want to remove any firewall rules you created.

Limitations

Currently this example cluster is not configured to use the built-in Backup/Restore feature of Vitess, because as of Vitess v2.0.0-alpha2 that feature requires a network-mounted directory. Usually this system is used to restore from the latest backup when a pod is moved or added in an existing deployment. As part of the final Vitess v2.0.0 release, we plan to provide support for saving backups in a cloud-based blob store (such as Google Cloud Storage or Amazon S3), which we believe will be better suited to running in Kubernetes.

Analytics