Skip to content

Instantly share code, notes, and snippets.

@joshuaquek
Last active June 13, 2020 17:02
Show Gist options
  • Save joshuaquek/7df09ad7864ded246e6e6f5047a94234 to your computer and use it in GitHub Desktop.
Save joshuaquek/7df09ad7864ded246e6e6f5047a94234 to your computer and use it in GitHub Desktop.
Summary: A step by step set of instructions on how to run a Kubernetes cluster locally, with one master node and as many worker nodes as you want ( 1 node = 1 virtual box vm instance )
Summary: A step by step set of instructions on how to run a Kubernetes cluster locally, with one master node and as many worker nodes as you want ( 1 node = 1 virtual box vm instance )

Running a Kubernetes Cluster Locally

This gist covers how to run a kubernetes cluster on multiple interconnected virtualbox VMs, locally on your laptop/desktop machine.

Pre-requisites

Setup

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.

Setting up the nodes

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;

Accessing the Cluster once setup is complete:

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.

Credits

https://github.com/oracle/vagrant-projects/tree/master/Kubernetes

oracle/vagrant-projects#62

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment