📔 Table of Contents
The purpose of this project is to deploy a fully functional Kubernetes cluster on a single machine within minutes, using one command only - "vagrant up".
Not a "minkube" or "light" Kubernetes - but a fully featured "Kubeadm" install deployed on Linux Ubuntu 22.04.
Vagrant doesn't just deploy the Kubernetes cluster - it provides, configures and manages all the underlaying infrastructure. Making possible to build and re-build whole systems in minutes. This makes simulation of complex environments on just one machine a breeze.
This release buids upon the work of - hfmartinez/kubernetes-vagrant, Innablr/K8s_ubuntu, exxsyseng/k8s_ubuntu and others, brings it up to date with latest OpenStack supported Kubernetes v.1.26, Ubuntu 22.04 LTS and expands with many additional options such as:
- Define any number of Worker nodes.
- Define any number of additional storage drives for Master/Worker nodes.
- Fully customized IP addreses and CIDR's.
- Choice of Kubernetes networking plugins: Flannel, Weave or Cillium [default].
- Option to Enable/Distable nested virtualization for guest VM's.
- Quality of life features like:
- Dynamic generation of guest VM's hosts file and hostnames.
- For CKA practice - Kube user, kubectl "k" alias, etc...
- Dynamic generation of guest VM's hosts file and hostnames.
- All managed in a dynamic way from a single configuration file.
This is not a PRODUCTION SETUP, it's aim is to simulate a full scale single machine/multi-node cluster for development and studies.
-
Install VirtualBox - and add/configure the top-most "Host-Only" Network Interface with ip 192.168.56.1
-
Install Vagrant - and add vagrant to vboxusers group (on Linux only).
sudo usermod -aG vboxusers vagrant
- Clone this repository:
git clone https://github.com/eli-pavlov/vagrant-kubernetes-EZ.git
- Enter the project directory:
cd vagrant-kubernetes-EZ
- Review config.yaml file:
vim config.yaml ##//(or edit using your editor of choice)//##
- Deploy the cluster:
vagrant up
- Check cluster state:
vagrant ssh master -c "kubectl get nodes -o wide"
- SSH (connect) to Master node by typing:
vagrant ssh master
or
ssh [email protected] -i .vagrant/machines/master/virtualbox/private_key #Login directly by providing vagrant generated private key.
The location of the private key of the master node on the host machine is : <PROJECT_FOLDER>/.vagrant/machines/master/virtualbox/private_key
or
---> Login directly to VirtualBox VM: <---
Username: "vagrant"
password: "vagrant"
- To delete the cluster and revert any changes made to host machine:
vagrant destroy -f
- VirtualBox with 2 virtual network adapters
- Vagrant
- GIT
- Check Virtualization is Enabled in BIOS:
In AMD machines the feature is called SVM
It is also a good practice to disable Windows HyperV when using VirtualBox:
Verify there are at least 2 virtual network adapters defined in VirtualBox, "Host-Only" adapter for host and cluster
internal communication.
And "NAT" adapter for access to the internet.
Configure the top-most "Host Only" Network adapter with ip adress of 192.168.56.1,
DHCP server address 192.168.56.2 and address boundaries from 192.168.56.3
to 192.168.56.254.
The adapter with the cluster IP address should be at the top of the list,
because the top adapter is always selected as the main Network adapter for
the VM.
IMPORTANT! "Host-Only" adapter's IP address should always match the addresses defined in config.yaml file.
File -> Tools -> Network Manager -> Create
Configure DHCP Server of "Host-Only" adapter:
Check NAT network adapter is present:
- Install Vagrant - and add vagrant to vboxusers group (on Linux only).
sudo usermod -aG vboxusers vagrant
- Install GIT
https://git-scm.com/downloads
- Clone this repository:
git clone https://github.com/eli-pavlov/vagrant-kubernetes-EZ.git
- Enter the project directory:
cd vagrant-kubernetes-EZ
- Review config.yaml file:
vim config.yaml ##//(or edit using your editor of choice)//##
- Deploy the cluster:
vagrant up
- Check cluster state:
vagrant ssh master -c "kubectl get nodes -o wide"
- SSH (connect) to the Master node by typing:
vagrant ssh master
or
ssh [email protected] -i .vagrant/machines/master/virtualbox/private_key #Login directly by providing vagrant generated private key.
he location of the private key of the master node on the host machine is : <PROJECT_FOLDER>/.vagrant/machines/master/virtualbox/private_key
or
---> Login directly to VirtualBox VM: <---
Username: "vagrant"
password: "vagrant"
- To delete the cluster and revert any changes made to host machine:
vagrant destroy -f
-
Vagrantfile: Main deployment file.
-
config.yaml: Main configuration file.
-
/scripts: Directory containing scripts and dynamically generated files. --> Press on the file names below for description.
requirements.sh:
-
- Script to install required packages on all VM's.
master.sh:
-
- Script to Install Master node specific packages and initialize the Kubernetes cluster.
worker.sh:
-
- Script to join worker nodes to the cluster.
-
/docs: Directory containing media files.
-
LICENSE.txt: License file.
-
README.md: Readme file formatted for Github, with information about the chart.
Distributed under the Apache License 2.0 License.
Please note that Kubernetes VirtualBox and Vagrant have their own respective licenses.
See LICENSE.txt for more information.
Eli Pavlov - www.weblightenment.com - [email protected]
Project Link: https://github.com/eli-pavlov/vagrant-kubernetes-EZ.git