This repository provides Vagrant resources various projects.
To install Vagrant on an Ubuntu machine with VirtualBox as the provider, run:
sudo apt update
sudo apt install virtualbox virtualbox-guest-additions-iso vagrant
# Install `kubectl` utility
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.28/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.24/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt update && sudo apt install kubectl
# Setup `kubectl` for use with VMs
vagrant ssh master -c "sudo cp /etc/kubernetes/admin.conf /vagrant"
echo "export KUBECONFIG=`pwd`/admin.conf" >> ~/.bashrc && export "KUBECONFIG=`pwd`/admin.conf"
kubectl get nodes
To clone this repository, use:
git clone https://github.com/purduecyan/vagrant.git
Navigate to the desired folder to create the necessary VMs. For example:
cd vagrant/kubernetes
Allow the network 172.42.42.0/24
for your VirtualBox machines
sudo mkdir /etc/vbox
sudo echo "* 172.42.42.0/24" >> /etc/vbox/networks.conf
Bring up the VMs using
vagrant up
Once the VMs are created, you can login to a VM using vagrant ssh
.
For example, after creating the kubernetes cluster, you can login to the master node using
vagrant ssh master
You can also stop all running VMs withing a project using
vagrant halt
To delete all the VMs created, run
vagrant destroy
You can find more information about Vagrant at https://www.vagrantup.com.