In this blog post, I’d like to share some experiences in setting up a Vitess environment for local tests and development on OSX/macOS. As previously, I have presented How To Test and Deploy Kubernetes Operator for MySQL(PXC) in OSX/macOS, this time I will be showing how to Run Vitess on Kubernetes.
Since running Kubernetes on a laptop is only experimental, I had faced several issues going through straight forward installation steps so I had to apply a few workarounds to the environment. This setup will have only minimum customization involved.
For a high-level overview of Vitess, please visit Part I of this series, Introduction to Vitess on Kubernetes for MySQL.
Housekeeping items needed during installation:
- Use and update homebrew
- Install minikube
- Install etcd operator
- Install helm
- Install mysql-client
- Install go 1.12+
- Install Vitess Client
Installation and Configuration
Minikube Installation
One of the main challenges I’ve faced was that the latest Kubernetes version wasn’t compatible with the existing development. The issue is filed here in GitHub, hence we start with the previous version, not the default.
1 2 3 4 5 6 7 8 9 10 11 12 |
$ minikube start -p vitess --memory=4096 --kubernetes-version=1.15.2 😄 [vitess] minikube v1.5.2 on Darwin 10.14.6 ✨ Automatically selected the 'virtualbox' driver 🔥 Creating virtualbox VM (CPUs=2, Memory=4096MB, Disk=20000MB) ... 🐳 Preparing Kubernetes v1.15.2 on Docker '18.09.9' ... 💾 Downloading kubelet v1.15.2 💾 Downloading kubeadm v1.15.2 🚜 Pulling images ... 🚀 Launching Kubernetes ... ⌛ Waiting for: apiserver 🏄 Done! kubectl is now configured to use "vitess" E1127 15:56:46.076308 30453 start.go:389] kubectl info: exec: exit status 1 |
Verify that the minikube is initialized and running.
1 2 3 4 5 6 7 8 9 10 11 |
$ kubectl -n kube-system get pods NAME READY STATUS RESTARTS AGE coredns-5c98db65d4-2zwsf 1/1 Running 0 1m coredns-5c98db65d4-qmslc 1/1 Running 0 1m etcd-minikube 1/1 Running 0 34s kube-addon-manager-minikube 1/1 Running 0 43s kube-apiserver-minikube 1/1 Running 0 41s kube-controller-manager-minikube 1/1 Running 0 28s kube-proxy-wrc5k 1/1 Running 0 1m kube-scheduler-minikube 1/1 Running 0 45s storage-provisioner 1/1 Running 0 1m |
Installation of etcd Operator
The next item on the list is to get etcd operator running. At this point, we’ll still need to clone etcd to local directory to have access to files.
1 |
$ git clone https://github.com/coreos/etcd-operator.git |
The issue reported here is a workaround to replace the deployment.yaml file. Once that’s done we can proceed with the installation.
Under /Users/[username]/Kubernetes/etcd-operator run;
1 2 3 4 5 6 7 8 9 10 11 12 |
$./example/rbac/create_role.sh Creating role with ROLE_NAME=etcd-operator, NAMESPACE=default clusterrole "etcd-operator" created Creating role binding with ROLE_NAME=etcd-operator, ROLE_BINDING_NAME=etcd-operator, NAMESPACE=default clusterrolebinding "etcd-operator" created $ kubectl create -f example/deployment.yaml deployment "etcd-operator" created $ kubectl get customresourcedefinitions NAME KIND etcdclusters.etcd.database.coreos.com CustomResourceDefinition.v1beta1.apiextensions.k8s.io |
If the above steps don’t work, alternatively you may install etcd-operator via helm.
1 2 3 4 5 |
$ kubectl get customresourcedefinitions NAME KIND etcdbackups.etcd.database.coreos.com CustomResourceDefinition.v1beta1.apiextensions.k8s.io etcdclusters.etcd.database.coreos.com CustomResourceDefinition.v1beta1.apiextensions.k8s.io etcdrestores.etcd.database.coreos.com CustomResourceDefinition.v1beta1.apiextensions.k8s.io |
Installation of helm
1 |
$ brew install helm |
Another issue faced with Helm is it can’t find tiller.
1 2 3 |
$ helm init $HELM_HOME has been configured at /Users/askdba/.helm. Tiller (the Helm server-side component) has been installed into your Kubernetes Cluster. |
Installation of Vitess Client
Get Vitess client installed using go:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
$ go get vitess.io/vitess/go/cmd/vtctlclient go: finding vitess.io/vitess v2.1.1+incompatible go: downloading vitess.io/vitess v2.1.1+incompatible go: extracting vitess.io/vitess v2.1.1+incompatible go: downloading golang.org/x/net v0.0.0-20191028085509-fe3aa8a45271 go: downloading github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b go: finding github.com/youtube/vitess v2.1.1+incompatible go: extracting github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b go: downloading github.com/youtube/vitess v2.1.1+incompatible go: extracting golang.org/x/net v0.0.0-20191028085509-fe3aa8a45271 go: extracting github.com/youtube/vitess v2.1.1+incompatible go: downloading github.com/golang/protobuf v1.3.2 go: downloading google.golang.org/grpc v1.24.0 go: extracting github.com/golang/protobuf v1.3.2 go: extracting google.golang.org/grpc v1.24.0 go: downloading google.golang.org/genproto v0.0.0-20191028173616-919d9bdd9fe6 go: downloading golang.org/x/text v0.3.2 go: downloading golang.org/x/sys v0.0.0-20191028164358-195ce5e7f934 go: extracting golang.org/x/sys v0. |