We are going to setup kubernetes cluster on VM using Vagrant.
- System RAM : 8 GB
- System CPU : 4 Cores
- System Disk : 20 GB(Free)
- System OS : Debian-Based Any OS(Tested on Ubuntu 20.04)
- Installed VirtualBox - (Ref for Installation : https://www.virtualbox.org/wiki/Linux_Downloads)
- Installed Vagrant - (Ref for Installation : https://www.vagrantup.com/downloads)
- Base Image : ubuntu/focal64
- CRI-O Version : Latest(1.27.0)
- Kubeadm Version : Latest(v1.27.0)
- Kubectl Version : Latest(v1.27.0)
- kubelet Version : Latest(v1.27.0)
- CNI : Weave Net(Latest) - Latest(v2.8.1)
Hostname | Componets |
---|---|
kube-master | kube-apiserver, kube-controller-manager, kube-scheduler, etcd, kubelet, docker, weave net |
kube-worker-1 | kubelet, kube-proxy docker, weave net |
kube-worker-n | kubelet, kube-proxy docker, weave net |
- Installation of require Vagrant plugins
vagrant plugin install vagrant-env vagrant-vbguest
- Clone the project and change directory to it.
git clone https://github.com/akshayithape-devops/Kubernetes-Setup-Using-Vagrant.git && cd Kubernetes-Setup-Using-Vagrant
- Customize your own environment file.
cp .env_example .env
- Notes for env file modification
1. We have to set bridge interface name in .env file.(You can use `ifconfig` or `ip` command to find interface name.)
2. As we used bridge, we have to assign the IP address to master & workers in same range of host system.
3. In .env file, You can define how many worker node is required.
4. In .env file, You can define memory and CPU requirement for master and workers.
- Start the Master and Worker nodes using
vagrant up
command.
# It will take around 25-30 mins to provisioning 3 VMs(1 Master & 2 Workers)
vagrant up
- Check the status of vagrant
vagrant status
- To connect Master & Worker Nodes using
vagrant ssh
command.
# To connect Master Node
vagrant ssh kube-master
# To connect Worker Nodes
# You have to replace n with worker node number.
vagrant ssh kube-worker-n
- To check all nodes are available in kubernetes cluster
# To connect Master Node
vagrant ssh kube-master
# On kube-master Node
kubectl get nodes
- To provision the project
vagrant provision
- To stop the running project
vagrant suspend
- To shutdown the running project
vagrant halt
- To restart the running project
vagrant up
- To delete the project
vagrant destroy -f
The latest version of Virtualbox for Linux can cause issues.
Create/edit the /etc/vbox/networks.conf file and add the following to avoid any network-related issues.
* 0.0.0.0/0 ::/0
or run below commands
sudo mkdir -p /etc/vbox/
echo "* 0.0.0.0/0 ::/0" | sudo tee -a /etc/vbox/networks.conf
So that the host only networks can be in any range, not just 192.168.56.0/21 as described here: https://discuss.hashicorp.com/t/vagrant-2-2-18-osx-11-6-cannot-create-private-network/30984/23