Logo

dev-resources.site

for different kinds of informations.

My Kubernetes Lab Setup - Using Vagrant & Docker

Published at
12/29/2023
Categories
kubernetes
minikube
lab
setup
Author
kabeer1choudary
Categories
4 categories in total
kubernetes
open
minikube
open
lab
open
setup
open
Author
15 person written this
kabeer1choudary
open
My Kubernetes Lab Setup - Using Vagrant & Docker

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Now start the vagrant VM

> vagrant up

vagrant-up
Login to the ubuntu VM as vagrant user

> vagrant ssh

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 
Enter fullscreen mode Exit fullscreen mode

get-docker-1

get-docker-2

get-docker-3

Add the vagrant user under docker group to fix permissions further.

~$ sudo usermod -aG docker $USER && newgrp docker
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

get-minikube

Now, set docker as default driver for our kubernetes cluster setup

~$ minikube config set driver docker
Enter fullscreen mode Exit fullscreen mode

set-docker-to-minikube

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
Enter fullscreen mode Exit fullscreen mode

start-minikube

We can verify the current running container components that constitute our Kubernetes cluster.

~$ minikube kubectl -- get pods -A
Enter fullscreen mode Exit fullscreen mode

get-pods-minikube

docker-ps

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
Enter fullscreen mode Exit fullscreen mode

stop-minikube

I hope these steps help you set up your own Kubernetes lab on your local machine to experiment and learn more. Thanks for reading.!

setup Article's
30 articles in total
Favicon
.NET DEVELOPER TOOLS NEED TO INSTALL FOR NEWLY PC
Favicon
Exploring Localhost 127.0.0.1:49342: Setup and Usage Guide
Favicon
Mastering Jenkins: A Step-by-Step Guide to Setting Up and Supercharging Your CI/CD Workflow
Favicon
Personal TODO list on how I set up my dev machine
Favicon
CĂłmo usar varias SSH keys para diferentes repositorios de GitHub (o GitLab)
Favicon
Tech and Tools I use
Favicon
How to Set Up a New TypeScript Project
Favicon
How to install SDL2 on macOS
Favicon
Multiple Node.js versions - setup memo
Favicon
Elevate Your Gaming Setup: Affordable Alternatives for Setup Gaming
Favicon
How to set up HTMX in Django
Favicon
Créez Votre Configuration p Jeu Parfaite : Découvrez nos Offres dès Aujourd'hui !
Favicon
Kitty + Neovim: Aesthetic Dev Setup
Favicon
Um pouco de mim
Favicon
Pop_OS Japanese layout
Favicon
The fastest setup of enhanced conversions for Google Ads.
Favicon
zsh: command not found: brew
Favicon
Dill Processing Plant Plant Project Report 2024, Setup Details, Machinery Requirements and Cost Analysis
Favicon
Hair Oil Manufacturing Plant Project Report 2024, Cost, Industry Trends and Business Opportunities
Favicon
Glutamic Acid Manufacturing Plant Project Report 2024, Machinery, Cost and Raw Material Requirements
Favicon
How to set up Python for backend development
Favicon
Setting Up Your macOS Development Environment and Automating Backups.
Favicon
What is use for work as a developer - Basic Flutter setup
Favicon
Trabalhando com 2 pc's no setup,Dicas!🖥️
Favicon
The JavaScript Developer's Guide to Ubuntu on Windows 11 with WSL
Favicon
My Kubernetes Lab Setup - Using Vagrant & Docker
Favicon
Setup MacMini M1 for Development
Favicon
Setup MacMini M1 for Development
Favicon
How to install and setup Neovim with awesome plugins
Favicon
Redis Local setup

Featured ones: