DevOps Tools

Setting Up VirtualBox, Minikube, and Kubectl

In this comprehensive guide, we will walk through the process of setting up a DevOps environment using VirtualBox, Minikube, and Kubectl on a Windows system. This setup is essential for anyone looking to get hands-on experience with container orchestration using Kubernetes.

1. VirtualBox

VirtualBox is a powerful x86 and AMD64/Intel64 virtualization product for enterprise as well as home use. It allows you to run multiple operating systems on your existing computer without having to modify your existing setup.

Installation Steps

  1. Download VirtualBox:
  1. Install VirtualBox:
  • Run the downloaded installer (VirtualBox-x.x.x-x-Win.exe).
  • Follow the installation wizard steps to complete the installation.
  • After installation, launch VirtualBox to ensure it is installed correctly.

Example Command Prompt Instructions

To verify that VirtualBox is installed correctly, you can use the following command in Command Prompt:

VBoxManage --version

This command should return the version of VirtualBox installed on your system.

2. Minikube and Kubectl

Minikube is a tool that makes it easy to run Kubernetes locally. Kubectl is a command-line tool for interacting with the Kubernetes cluster.

Prerequisites

  • Required Hyper-V: Ensure Hyper-V is enabled on your Windows machine.

Installation Steps

  1. Install Chocolatey:
    Chocolatey is a package manager for Windows which simplifies the installation process.
  • Open Command Prompt as Administrator.
  • Run the following command to install Chocolatey:
    sh @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
  1. Install Minikube:
  • Download and install Minikube using Chocolatey:
    sh choco install minikube
  1. Download and Install kubectl:
  • Download kubectl using curl:
    sh curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.17.0/bin/windows/amd64/kubectl.exe
  • Move the downloaded kubectl.exe to a directory included in your system PATH, such as C:\Windows\System32.
  • Update the PATH environment variable if necessary:
    sh setx PATH "%PATH%;C:\path\to\kubectl"

Verify Installation

  1. Check kubectl version:
   kubectl version --client

This command should return the version of kubectl installed.

  1. Start Minikube:
   minikube start
  1. Check Minikube status:
   minikube status

This command verifies that Minikube is running.

Minikube and kubectl Commands

Here are some essential Minikube and kubectl commands to manage your Kubernetes environment:

  • Check Minikube status:
  minikube status
  • Start Minikube:
  minikube start
  • Stop Minikube:
  minikube stop
  • Delete Minikube cluster:
  minikube delete
  • Get cluster nodes:
  kubectl get nodes
  • List all pods:
  kubectl get pods
  • List all deployments:
  kubectl get deployments
  • Delete a specific pod:
  kubectl delete pod webapp
  • Delete a specific deployment:
  kubectl delete deployment webapp

Example: Deploying and Managing a Simple Application

  1. Create a deployment:
   kubectl create deployment webapp --image=nginx
  1. Expose the deployment:
   kubectl expose deployment webapp --type=NodePort --port=80
  1. List services to get the NodePort:
   kubectl get services
  1. Access the application:
    Open a web browser and navigate to http://<minikube_ip>:<node_port> to see the Nginx welcome page.

By following these steps, you should have a fully functional Kubernetes environment running locally on your Windows machine. This setup provides a great way to learn and experiment with Kubernetes and its various features.

Ali Imran
Over the past 20+ years, I have been working as a software engineer, architect, and programmer, creating, designing, and programming various applications. My main focus has always been to achieve business goals and transform business ideas into digital reality. I have successfully solved numerous business problems and increased productivity for small businesses as well as enterprise corporations through the solutions that I created. My strong technical background and ability to work effectively in team environments make me a valuable asset to any organization.
https://ITsAli.com

Leave a Reply