Running Wordpress using Kubernetes locally

Our aim with this post is to describe the process to run Kubernetes locally, by demonstrating running MySQL and Wordpress on the Kubernetes cluster.

We won't explain what Kubernetes is, suffice to say it is the container orchestration solution that everyone seems to be leaning towards; normally you'd want to run up a Kubernetes cluster on a cloud provider such as AWS or GCE, however for the purposes of training / evaluation, we run it up locally using a cluster of Vagrant virtual machines.

Prerequisites

We assume we're on Mac OSX, though the Vagrantfile is OS-agnostic, so you should be able to get things working on both Windows and Linux relatively easily.

Note that we specify that we want the web-based user interface; other settings are described in the project's README.md, but do take a look through the Vagrantfile to get a better idea about what values can be supplied.

The cluster startup will likely take some time, as vagrant will most likely need to pull a number of images; the Vagrantfile does allow the following providers, though we're using Virtualbox here:

The Kubernetes dashboard

During the creation of the cluster, you'll see messages regarding the creation of the kubernetes-dashboard:

==> master: Configuring Kubernetes dashboard...
deployment "kubernetes-dashboard" created
service "kubernetes-dashboard" created
==> master: Kubernetes dashboard will be available at http://172.17.8.101:8080/ui

Note: Any other Type of PersistentVolume would allow you to recreate the Deployments and Services at this point without losing data, but hostPath loses the data as soon as the Pod stops running. However, for the purposes of this demonstration, we're not worried about persisting data.