A simple lab using Vagrant and Virtualbox to learn to setup and manage a Kubernetes environments based on Kubeadm.
Vagrant: https://www.vagrantup.com/downloads
Virtualbox: https://www.virtualbox.org/wiki/Downloads
The Vagrant images are based on Ubuntu Bionic64. There's no real preference for Ubuntu besides me wanting to use it. Please feel free to refer to the Kubeadm documentation for instrucions on installing on other Linux distributions.
Clone this repo.
Edit the Vagrantfile to suit your resource requirements. In this configuration, there's a 1 master, 2 worker node cluster.
MASTER_CPU = 2
MASTER_RAM = 2048
WORKER_CPU = 4
WORKER_RAM = 4096
WORKER_COUNT = 2
BOX_IMAGE = "ubuntu/bionic64"
Vagrant.configure("2") do |config|
config.vm.define "master", primary: true do |kubeconfig|
kubeconfig.vm.box = BOX_IMAGE
kubeconfig.vm.hostname = "master"
kubeconfig.vm.network "private_network", type: "dhcp"
kubeconfig.vm.provider "virtualbox" do |vb|
vb.cpus = MASTER_CPU
vb.memory = MASTER_RAM
end
kubeconfig.vm.provision "shell", inline: "sudo /vagrant/installKubernetes.sh master"
end
(1..WORKER_COUNT).each do |i|
config.vm.define "worker#{i}" do |kubeconfig|
kubeconfig.vm.box = BOX_IMAGE
kubeconfig.vm.hostname = "worker#{i}"
kubeconfig.vm.network "private_network", type: "dhcp"
kubeconfig.vm.provider "virtualbox" do |vb|
vb.cpus = WORKER_CPU
vb.memory = WORKER_RAM
end
kubeconfig.vm.provision "shell", inline: "sudo /vagrant/installKubernetes.sh worker"
end
end
config.vm.box_check_update = false
end
Once the resource configuration has been set, bring up the Vagrant environment
vagrant up
vagrant ssh master
sudo su -
kubectl get nodes -o wide
For those of you not interested in using the root account. You can run the following command to configure the kubectl config for the vagrant user.
vagrant ssh master
/vagrant/installKubernetes.sh user
You can connect to the worker nodes by running the command below.
vagrant ssh worker1