Local Kubernetes Cluster w/ Vagrant and Ansible

I published a repository on GitHub: https://github.com/snajdov/kubernetes-local
This repo helps you start a single master, multi worker local Kubernetes cluster.
It uses the latest version of Kubernetes and its dependencies, which can be updated.
This cluster can be used for local testing and learning.

Cluster Structure

This repo starts a single master node using a Vagrant VM machine running Ubuntu 23.10 (Mantic).

It also starts two other Vagrant VMs that join this master node as workers. Also running Ubuntu 23.10 (Mantic).

All VMs are on the network 192.168.50.0/24 with .10 being the master and .11 and onwards, being the workers.
Additionally, a pod cluster network is set up at 10.88.0.0/16.

Building the cluster

To start this cluster, all you have to do is run: vagrant up inside the repo folder.

Prerequisites to running this are:

  • Installed vagrant
  • Installed ansible
  • Installed vagrant provider (e.g. VirtualBox or similar)
  • 6 GiB of RAM (2 GiB per node)
  • 6 CPU Threads (2 threads per node)

After successfull running of vagrant up, the kubectl config file will be stored in kubernetes-setup.
Or, you can ssh into the master node where it’s already set up: vagrant ssh k8s-master.

Configuration

Versions

If you want to change the version Kubernetes and its dependencies, change the values in the Vagrantfile.
Links to the latest releases are provided in the file, as well.

VMs

The Vagrantfile also contains information about the VM’s OS image to be used, and RAM and CPU to be provisioned to each VM.
Note that, kubeadm requires at least 2 GiB of RAM, and at least 2 CPU threads. More info on this, here.

Run workloads

You now have a running cluster. Feel free to test out anything on it.
See the README.md example on the GitHub repo, here.