This gist covers how to run a kubernetes cluster on multiple interconnected virtualbox VMs, locally on your laptop/desktop machine.
- Make sure that you have virtualbox installed: https://www.virtualbox.org/wiki/Downloads
- Make sure that you have vagrant installed: https://www.vagrantup.com/downloads.html
Clone the repository to your local machine:
git clone https://github.com/oracle/vagrant-boxes
Go into the folder:
cd vagrant-boxes
After that, open the Vagrantfile and change MANAGE_FROM_HOST variable from false
to true
.
Also, if you wish to have more than 2 worker nodes/vm instances, you can open the Vagranrfile and set the NB_WORKERS from 2
to whatever number you wish, depending on how many VMs you want.
This will be the "master" virtualbox vm instance for your cluster.
vagrant up master; vagrant ssh master;
In another terminal:
vagrant up worker1; vagrant ssh worker1;
In another terminal:
vagrant up worker2; vagrant ssh worker2;
If you wish to have more workers, rememeber to change the NB_WORKERS
in the Vagrantfile to that number, and then you can provision more workers.
Let's say I have set NB_WORKERS
to 3
then I can provision another worker node using the following command:
vagrant up worker3; vagrant ssh worker3;
Run the following to add the cluster settings to your kubeconfig
export KUBECONFIG=$(pwd)/admin.conf
After that, check that you can connect to it:
kubectl get nodes
The command above should then print out your master node and worker nodes.
https://github.com/oracle/vagrant-projects/tree/master/Kubernetes