1-a: Create environment: Install Minikube in Windows 11 (WSL2.0 + Ubuntu22.04)

  1. Install WSL2.0 with Windows Command Prompt or PowerShell

     wsl --install
    
  2. Install Ubuntu 22.04

     wsl --list --online 
     wsl --install -d Ubuntu22.04
     sudo apt update
     sudo apt upgrade
    
    • wsl --list --online

      • This command is used in Windows Subsystem for Linux (WSL), a compatibility layer for running Linux binary executables natively on Windows.

      • --list is an option to display a list of installed Linux distributions.

      • --online is an option to show distributions available for download from the Microsoft Store.

    • wsl --install -d Ubuntu22.04

      • --install is an option to install a new Linux distribution.

      • -d specifies the distribution to be installed, in this case, "Ubuntu22.04."

    • sudo apt update

      • This command is used in a Linux environment, typically in Debian-based distributions like Ubuntu.

      • sudo stands for "superuser do" and is used to execute commands with elevated privileges.

      • apt is the package management tool.

      • update is a command that refreshes the local package database, ensuring you have the latest information about available packages.

    • sudo apt upgrade

      • upgrade is a command that installs the latest versions of the installed packages on your system.

      • It is common to run apt update before apt upgrade to ensure that the package information is up-to-date.

  3. Install Docker engine

     for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done
    
     sudo apt-get update
     sudo apt-get install ca-certificates curl gnupg
     sudo install -m 0755 -d /etc/apt/keyrings
     curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
     sudo chmod a+r /etc/apt/keyrings/docker.gpg
     echo \
       "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
       "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
       sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
     sudo apt-get update
    
     sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
     sudo docker run hello-world
    
    • See: https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository

    • for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done

      • This loop iterates over a list of packages related to containerization tools (like Docker and Podman) and removes them using the sudo apt-get remove command.
    • sudo apt-get update

      • This command updates the package information on your system, ensuring you have the latest details about available packages.
    • sudo apt-get install ca-certificates curl GnuPG

      • This installs essential tools (ca-certificates, curl, and gnupg) needed to securely handle certificates, download files, and manage cryptographic keys.
    • sudo install -m 0755 -d /etc/apt/keyrings

    • curl -fsSL download.docker.com/linux/ubuntu/gpg

    • sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

    • sudo chmod a+r /etc/apt/keyrings/docker.gpg

      • This creates a directory for keyrings, downloads Docker's GPG key, converts it into the required format, and sets the necessary permissions.
    • echo "deb [arch="$(dpkg --print-architecture)" ....

      • This command adds Docker's official repository to the list of package sources, specifying the architecture and GPG key for verification.
    • sudo apt-get update

    • sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

      • This installs Docker, Docker CLI, Containerd (core container runtime), and additional plugins (docker-buildx-plugin and docker-compose-plugin).
    • sudo docker run hello-world

      • Finally, this command pulls the "hello-world" Docker image and runs a container to verify that Docker is installed and working correctly.
  4. Install Docker Compose

     sudo -i
     curl -L https://github.com/docker/compose/releases/download/1.6.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
     chmod +x /usr/local/bin/docker-compose
     exit
     docker-compose --version
    
    • sudo -i

      • This command elevates the user's privileges to the root user, providing an interactive root shell.
    • curl -L https://github.com/docker/compose/releases/download/1.6.2/docker-compose-uname -s-uname -m > /usr/local/bin/docker-compose

      • This uses curl to download the Docker Compose binary for a specific release (1.6.2 in this case) based on the current system's architecture and operating
    • chmod +x /usr/local/bin/docker-compose

      • This command adds the execute permission to the downloaded Docker Compose binary, making it executable.
    • exit

      • This command exits the root shell, returning to the previous user's shell.
    • docker-compose --version

      • Finally, this command checks the version of Docker Compose installed on the system. It prints out the version information to confirm a successful installation.
  5. Install Minikube

    • See: https://minikube.sigs.k8s.io/docs/start/

        curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
        sudo install minikube-linux-amd64 /usr/local/bin/minikube
        sudo usermod -aG docker $USER && newgrp docker
        minikube start --driver=docker
      
  6. Install kubectl

     sudo snap install --classic kubectl
    
    • snap is the command-line interface for the Snap package manager.

    • install is the subcommand used to install a Snap package.

    • --classic flag is used to indicate that the Snap package requires classic confinement, which provides full access to the system.

    • kubectl is the name of the Snap package being installed.

  7. Install Helm

    • https://helm.sh/docs/intro/install/

        wget https://get.helm.sh/helm-v3.12.3-linux-amd64.tar.gz
        tar xvfz helm-v3.12.3-linux-amd64.tar.gz
        sudo mv linux-amd64/helm /usr/local/bin/helm
      

Additional notes: Basic commands to operate Minikube

  • Start Minikube with static IP

  • Delete a cluster in Minikube

    • minikube delete
  • Stop Minikube

    • minikube stop