Setup Local Kubernetes using Vagrant and Kubespray

Plan your setup

Since I am preparing my local laptop lab, my setup will include:

Total Memory: 1,5 Gb; Total vCPU’s: 6;


Clone Kubespray

git clone

Then checkout a tag version (check TAGs:

I am using: v2.13.2

cd kubespray
git checkout v2.13.2

Check requirements:

Since I am using Mac, I need to check Python3 version by using:

First prepare Mac to add Python3 and Pip3:

brew install python3
brew postinstall python3
curl -O
sudo python3

Check installed versions

python3 --version
pip3 --version

My versions are:

Tool Version
Python3 3.8.3
Pip3 20.1.1

Check and install the requirements needed:

cat requirements.txt
pip3 install -r requirements.txt

Check your configuration

First check your Vagrantfile:

nano Vagrantfile

At least set cpu no to 2:

$vm_cpus ||= 2

And set memory according to your available machine memory:

$vm_memory (by default 2Gb)


vagrant up


vagrant halt

Copy configuration to admin kubernetes

mkdir ~/.kube
cp inventory/sample/artifacts/admin.conf ~/.kube/config

Check everything is running:

kubectl cluster-info
kubectl version --short
kubectl get nodes -o wide
kubectl get cs
kubectl get ns
kubectl -n kube-system get all

Check if network is running as well:

First check that nothing is running:

kubectl get all

Run nginx with 3 replicas

kubectl run nginx --image nginx --replicas 3

Check and wait until all 3 replicas are running

kubectl get all -o wide

After all 3 replicas are running, connect to one of them by using:

kubectl exec -it nginx-6db489d4b7-bcjrl -- bash

Replace nginx-6db489d4b7-bcjrl with your container identifier.

Inside the container install ping, and test ping all the other containers IP addresses found with kubectl get all -o wide.

apt update
apt install -y iputils-ping
hostname -i
ping <other container ip>

If you can ping, your flannel network is OK!


kubectl delete deploy nginx

Setup kubernetes dashboard

First get the token

kubectl create -f contrib/misc/clusteradmin-rbac.yml
kubectl -n kube-system describe secret kubernetes-dashboard-token | grep 'token:' | grep -o '[^ ]\+$'

Copy the token

Proxy dashboard

kubectl proxy

Access using the above URL (adapt the port if needed):

Use token to login.