Skip to content

Latest commit

 

History

History
62 lines (55 loc) · 1.81 KB

README.md

File metadata and controls

62 lines (55 loc) · 1.81 KB

Vagrant Resources

This repository provides Vagrant resources various projects.

Getting Started

Install Vagrant and VirtualBox

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 and configure kubectl

# 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

Clone the repository

To clone this repository, use:

git clone https://github.com/purduecyan/vagrant.git

Create the VMs

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

Teardown

To delete all the VMs created, run

vagrant destroy

Additional resources

You can find more information about Vagrant at https://www.vagrantup.com.