My everyday driver is a Windows 10 PC, and today we will install minikube on Ubuntu 20.04 running as a Vagrant VM. I have already installed Hashicorp's Vagrant and Oracle VirtualBox on the PC to build up several environments for testing.
You may know more about Vagrant from here, and get both downloaded from here (Vagrant, VirtualBox). Post installing Vagrant & Virtualbox now time to get our Kubernetes lab setup up and running.
What is Minikube ?
Minikube is an open-source tool that enables developers to easily set up and manage local Kubernetes clusters for development and testing purposes. By creating a single-node Kubernetes cluster within a virtual machine on the user's local machine, Minikube provides a convenient and isolated environment for simulating Kubernetes deployments. Its user-friendly command-line interface, compatibility with various virtualization drivers, and support for Kubernetes addons make Minikube an essential tool for developers looking to learn, experiment, and develop applications in a controlled Kubernetes environment without the need for a full-scale cluster.
Setting up the Vagrant directory & file
Open your Powershell terminal, create a directory and initiate vagrant to generate boilerplate file called Vagrantfile, which will be the config file for your vagrant ubuntu VM.
> mkdir ubuntu2004; cd ubuntu2004; mkdir data
> vagrant init
Modify the Vagrantfile to get Ubuntu 20.04 and other necessary configurations as below
Vagrant.configure("2") do |config| #start of the config
config.vm.box = "generic/ubuntu2004" #get ubuntu 20.04 generic image
config.vm.synced_folder "./data", "/vagrant_data" #make a dir to share files between host & VM
config.vm.network "private_network", ip: "192.168.33.10" #set the ip as private
config.vm.provider "virtualbox" do |vb| #use virtualbox to provision the VM
vb.gui = true #set GUI while starting the VM
vb.memory = "8192" #set RAM for VM
vb.cpus = 4 #set CPU count for VM
end
end
Now start the vagrant VM
> vagrant up
Login to the ubuntu VM as vagrant user
> vagrant ssh
Installing Docker, Drivers & Minikube
Using below commands to install docker & drivers
~$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add
~$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
~$ sudo apt update
~$ sudo apt install docker-ce docker-ce-cli containerd.io
~$ sudo systemctl status docker
Add the vagrant user under docker group to fix permissions further.
~$ sudo usermod -aG docker $USER && newgrp docker
Download the minikube binaries and install on the VM
~$ curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
~$ sudo install minikube-linux-amd64 /usr/local/bin/minikube
Now, set docker as default driver for our kubernetes cluster setup
~$ minikube config set driver docker
Start Minikube, Check Kubernetes cluster status, & Remove
Let's start our Minikube cluster to kickstart our Kubernetes lab setup. (It will take few minutes, depend on your internet speed & supplied resources.)
~$ minikube start
We can verify the current running container components that constitute our Kubernetes cluster.
~$ minikube kubectl -- get pods -A
Now, we can use this lab setup to practice and test more about Kubernetes. When your tasks are over, we can stop the cluster and reprovision as needed.
~$ minikube stop
~$ minikube delete
I hope these steps help you set up your own Kubernetes lab on your local machine to experiment and learn more. Thanks for reading.!
Top comments (0)