Skip to content

Using vagrant and kubeadm to bootstrap a k8s cluster

License

Notifications You must be signed in to change notification settings

sofianinho/vagrant-kube

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kubernetes cluster with vagrant and kubeadm

Simple vagrantfile for any sized cluster (master + workers) in Ubuntu 18.04 VMs. Very configurable through 2 env variables.

Note

If you want to experiment using a cluster with CRI-O instead of Docker as a CNI, you can use the branch "crio" of this project.

Use

The following commands for instance will bootstrap a kubernetes cluster with a master and 2 workers with a specific private subnet:

export VAGRANT_SUBNET=192.168.195.0 
export VAGRANT_WORKERS=2 
vagrant up

Default values for workers and subnet are 1 and 192.168.66.0, respectively

Full list of possible configurations

Variable Definition Default Example value
VAGRANT_SUBNET Private subnet for VMs where the cluster is formed and peered.
Master is at .100 and Workers start at .150
192.168.66.0 192.168.178.0, 10.10.0.0
VAGRANT_WORKERS Number of workers in the cluster (master is also a worker) 1 5
VAGRANT_MASTER_RAM Memory for the master 2048 4096, 1024
VAGRANT_MASTER_CPU Number of CPUs for the master 1 2
VAGRANT_WORKER_RAM Memory per worker 2048 4096, 1024
VAGRANT_WORKER_CPU Number of CPUs for per worker 1 2

Interact with the cluster remotely (from host)

For that, I find the simplest way is to copy your cluster config outside of the master vm and use kubectl with --kubeconfig flag

vagrant ssh master
cp .kube/config /vagrant
exit
export KUBECONFIG=$KUBECONFIG:$PWD/config
kubectl config view #see that the new config has been added
kubectl get nodes #see that the nodes you created are visible

To make this step more secure, follow instructions from here and this cheatsheet.

LICENSE

MIT

About

Using vagrant and kubeadm to bootstrap a k8s cluster

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages