Multi node Kubernetes clusters offer a production-like environment which has various advantages. Even though Minikube provides an excellent platform for getting started, it doesn’t provide the opportunity to work with multi node clusters which can help solve problems or bugs that are related to application design and architecture. For instance, Ops can reproduce an issue in a multi node cluster environment, Testers can deploy multiple versions of an application for executing test cases and verifying changes. These benefits enable teams to resolve issues faster which make the more agile.
Vagrant: is a tool for building and managing virtual machine environments in a single workflow and by far the easiest and fastest way to create a virtualized environment, and an effective way of deploying Kubernetes. In order for vagrant to work, you’ll need a virtual machine provider such as VirtualBox, VMware or Hyper-V.
You should install VirtualBox and Vagrant before you start.
Vagrant must first be installed on the machine you want to run it on. To make installation easy, Vagrant is distributed as a binary package for all supported platforms and architectures. Installing Vagrant is extremely easy. Head over to the Vagrant downloads page and get the appropriate installer or package for your platform. Install the package using standard procedures for your operating system.
After vagrant has been installed. You can verify its installation by running the binary to show the version
root@ubuntuvm01:~# ./vagrant version
Installed Version: 2.2.6
Latest Version: 2.2.6
You're running an up-to-date version of Vagrant!This may be necessary if it isn’t already installed on your system
apt-get install git -yI am using one from Randomly
git clone https://github.com/sayems/kubernetes.resources.git
Navigate to k8s-vagrant directory
$ cd kubernetes.resources/k8s-vagrant/
Navigate to k8s/ directory and then run the following command to start the Vagrant:
$ vagrant upNow, wait for kubernetes cluster to be ready. This might take a while to complete
Vagrantfile: The primary function of the Vagrantfile is to describe the type of machine required for a project, and how to configure and provision these machines. In this file, you will have settings such as operating system type, hostnames of your VMs in the cluster, node count for a few examples. The file also specifies the bootstrap scripts.
bootstrap.sh: This file is a basic set of initial instructions that will generally be applied to both the master Kubernetes node and the worker nodes as well. It does things such as update the /etc/hosts file to include all the nodes, installs docker, disable selling and firewalld. It also installed Kubernetes
bootstrap_kmaster.sh: This file Initialize Kubernetes, create the flannel network
bootstrap_kworker: This script will join the worker nodes to the cluster
- Almost all interaction with Vagrant is done through the command-line interface. The interface is available using the vagrant command, and comes installed with Vagrant automatically. The vagrant command in turn has many sub commands.
Once the cluster is completed build you can check the status of there system with the status flag.
$~/kubernetes/vagrant-provisioning$ vagrant status
Current machine states:
kmaster running (virtualbox)
kworker1 running (virtualbox)
kworker2 running (virtualbox)To log into the head node or any of the nodes in the cluster simply run “vagrant ssh .
$~/kubernetes/vagrant-provisioning$ vagrant ssh kmaster
Last login: Wed May 18 00:27:31 2020Your Cluster is now ready to use. You can verify by running “kubectl get nodes”.
[vagrant@kmaster ~]$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
kmaster.example.com Ready master 14m v1.16.2
kworker1.example.com Ready <none> 11m v1.16.2
kworker2.example.com Ready <none> 9m8s v1.16.2