There are many solutions to run a complete Kubernetes cluster in a VM on your machine, minikube, microk8s or even with kubeadm. So embarking into what others have done before me, I wanted to do the same with RKE. Mostly because I work with Rancher2 lately and I want to experiment on VirtualBox without remorse.
Enter rkube (the name directly inspired from minikube and rke). It does not do the many things that minikube does, but it is closer to my work environments.
We use vagrant to boot an Ubuntu Bionic box. It creates a 4G RAM / 2 CPU machine. We provision the machine using ansible_local and install docker from the Ubuntu archives. This is version 17 for Bionic. If you need a newer version, check the docker documentation and modify ansible.yml accordingly.
Once the machine boots up and is provisioned, it is ready for use. You will find the kubectl configuration file named kube_cluster_config.yml installed in the cloned repository directory. You can now run a simple echo server with:
kubectl --kubeconfig kube_cluster_config.yml apply -f echo.yml
Check that the cluster is deployed with:
kubectl --kubeconfig kube_cluster_config.yml get pod kubectl --kubeconfig kube_cluster_config.yml get deployment kubectl --kubeconfig kube_cluster_config.yml get svc kubectl --kubeconfig kube_cluster_config.yml get ingress
and you can visit the echo server at http://192.168.98.100/echo Ignore the SSL error. We have not created a specific SSL certificate for the Ingress controller yet.
You can change the IP address you can connect to the RKE VM in the Vagrantfile.
Suppose you now want to upgrade the Kubernetes version.
vagrant ssh into the VM and run
rke config -l -s -a and pick the new version that you want to install. Look for the containers named hypercube. You now edit /vagrant/cluster.yml and run
rke up --config /vagrant/cluster.yml.
Note that thanks to vagrant’s niceties, the
/vagrant directory within the VM is the directory you cloned the repository into.
I developed the whole thing in Windows 10, so it should be able to run just about anywhere. I hope you like it and help me make it a bit better if you find it useful.
You can browse rkube here