Create a local kubernetes cluster using virtualbox. A modification of the great work danielepolencic did in his gist.
The vagrant file will do the following:
- Provision all local VMs using VirtualBox
- Patch the OS
- Install Docker
- Install k8s control plane
- Initialize cluster with Flannel CIDR block & install Flannel
- Join the nodes to the master
- Create and copy the SSH key to all machines so you can SSH to any node from the Master. Add names & IPs to the local hosts file on each master and node. Create alias in vagrant home for kubectl...just use k
- Make required Ubuntu OS mods for the cluster to function properly
You should install VirtualBox and Vagrant before you start.
Open a shell and install the vagrant disksize plugin:
$ vagrant plugin install vagrant-disksize
Instal git if you don't already have it.
$ git clone [email protected]:LocusInnovations/k8s-vagrant-virtualbox.git
$ cd k8s-vagrant-virtualbox
You can create the cluster with:
$ vagrant up
You can delete the cluster with:
$ vagrant destroy -f
SSH to Master and other Nodes:
$ vagrant ssh master
$ vagrant ssh node1
$ vagrant ssh node2
$ vagrant ssh node3
Get the status of the Nodes:
$ k get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
master Ready master 16m v1.17.4 10.0.0.10 <none> Ubuntu 18.04.4 LTS 4.15.0-88-generic docker://19.3.6
node1 Ready <none> 11m v1.17.4 10.0.0.11 <none> Ubuntu 18.04.4 LTS 4.15.0-88-generic docker://19.3.6
node2 Ready <none> 6m31s v1.17.4 10.0.0.12 <none> Ubuntu 18.04.4 LTS 4.15.0-88-generic docker://19.3.6
node3 Ready <none> 102s v1.17.4 10.0.0.13 <none> Ubuntu 18.04.4 LTS 4.15.0-88-generic docker://19.3.6
SSH to other Nodes in the cluster from the Master:
$ ssh node1
$ ssh node2
$ ssh node3