MySQL Operator
A Kubernetes custom resource and Operator that allows a user to describe a trivial single-instance of MySQL. The tasks for running a single-instance stateful application are done by this operator.
Pre-reqs
You can run Kubernetes locally with
Minikube.
Building
dep ensure
CGO_ENABLED=0 GOOS=linux go build
docker build -t mysql-operator:0.1 .
docker save mysql-operator:0.1 | eval $(minikube docker-env)
Using the Operator
kubectl create -f mysql-operator.yaml
kubectl create -f mysql-resource.yaml
kubectl run -it --rm --image=mysql:5.6 --restart=Never mysql-client -- mysql -h mysql -ppassword
There is no support for updating the resource because there is nothing in its
spec that will allow for a non-disruptive change to the service. To make
changes to the service, it's recommended to tear it down and redeploy.
Cleanup
kubectl delete -f mysql-resource.yaml
kubectl delete -f mysql-operator.yaml