Minikube: Easy Local Kubernetes Setup and First Pod

Minikube: Easy Local Kubernetes Setup and First Pod

Introduction

Minikube provides a straightforward way to set up a local Kubernetes environment, allowing users to experience the power of Kubernetes without the complexities of a full-scale cluster. This guide covers the easy installation of Minikube and walks through the process of deploying your first pod, offering a practical introduction to container orchestration. Join this user-friendly tutorial to begin exploring the capabilities of Kubernetes in a simplified, local environment.

What is minikube?

Minikube is a quick way to set up a small Kubernetes system on your computer. It's like a simplified version of Kubernetes that's easy to use, making it great for beginners and smaller projects. Minikube works on different operating systems and can be set up as a virtual machine, a container, or on your computer directly. It's a handy tool with features like support for different ways to run containers and easy installation of extra Kubernetes apps.

Features of minikube:-

  1. Latest Kubernetes Support: It supports the latest Kubernetes release along with the six previous minor versions.

  2. Cross-Platform Compatibility: Minikube works seamlessly on Linux, macOS, and Windows operating systems.

  3. Deployment Flexibility: It can be set up as a virtual machine, a container, or directly on bare metal.

  4. Container Runtimes: Minikube supports multiple container runtimes, including CRI-O, containerd, and Docker.

  5. Efficient Image Handling: It provides a direct API endpoint for swift image loading and building.

  6. Advanced Functionality: Minikube offers features like LoadBalancer, filesystem mounts, feature gates, and network policy.

  7. Addon Support: It allows for easy installation of additional Kubernetes applications.

  8. Compatibility with CI Environments: Minikube is designed to work smoothly in common Continuous Integration (CI) setups.

Step-by-Step Guide for Minikube Installation on Ubuntu

Prerequisites:

Certainly! Here are the points with their respective headings:

  1. Processor Requirements

    • 2 or more CPUs
  2. Memory Requirements

    • 2GB of available memory
  3. Disk Space Requirements

    • 20GB of free disk space
  4. Internet Connection

    • Internet connection
  5. Container or VM Manager

    • A container or virtual machine manager is needed. Options include:

      • Docker

      • Hyperkit

      • Hyper-V

      • Podman

      • VirtualBox

      • VMware Fusion/Workstation.

Step 1: Update System Packages

First things first, we need to ensure we're up-to-date. Run the following command to get the latest package information:

sudo apt update

Step 2: Install Required Packages

Install some basic required packages.

sudo apt install -y curl wget apt-transport-https

Step 3: Install Docker

Minikube can run a Kubernetes cluster either in a VM or locally via Docker. This guide demonstrates the Docker method.

sudo apt install -y docker.io

Enable Docker.

sudo systemctl enable --now docker

Add current user to docker group (To use docker without root)

sudo usermod -aG docker $USER && newgrp docker

Remember to Reboot Your Computer

sudo systemctl reboot

Step 4: Install Minikube

First, download the Minikube binary using curl:

curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64

Make it executable and move it into your path:

chmod +x minikube
sudo mv minikube /usr/local/bin/

Step 5: Install kubectl

Download kubectl, which is a Kubernetes command-line tool.

curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"

Make it executable and move it into your path:

chmod +x kubectl
sudo mv kubectl /usr/local/bin/

Step 6: Start Minikube

Now, you can start Minikube with the following command:

minikube start --driver=docker

This command will start a single-node Kubernetes cluster inside a Docker container.

Step 7: Check Cluster Status

Ensure everything's up and running.

minikube status

Step 8: Stop Minikube

When you're finished with your Kubernetes adventures then stop the minikube.

minikube stop

Optional: Delete Minikube Cluster

If you wish to delete the Minikube cluster entirely, you can do so with:

minikube delete

What is Pod??

A Pod in Kubernetes is the smallest deployable unit of computing. It represents a single instance of an application and can consist of one or more containers that share resources like storage and network. These containers within a Pod are scheduled and run together on the same node in the Kubernetes cluster. Pods are used for running applications and can be scaled horizontally by creating more instances. They are essential for managing applications in Kubernetes.

Task: Create your first pod on Kubernetes through minikube.

Step 1: Start Minikube

minikube start

Step 2: Define a Pod YAML File

Create a file named first-pod.yaml and add the following content:

apiVersion: v1
kind: Pod
metadata:
  name: nginx
  namespace: nginx
spec:
  containers:
  - name: nginx
    image: nginx:latest
    ports:
    - containerPort: 80

This YAML file defines a simple pod with one container running the Nginx web server.

Step 3: Apply the YAML File

Apply the YAML file to create the pod:

kubectl apply -f first-pod.yaml

Step 4: Check the Status of the Pod

You can check the status of your pod using the following command:

kubectl get pods -n nginx

-n is used for the namespace

It may take a few moments for the pod to go from "ContainerCreating" to "Running" status.

Congratulations! You have successfully created your first pod on Kubernetes using Minikube.

Conclusion

In conclusion, this guide introduced Minikube as a simplified way to set up a local Kubernetes environment, allowing users to experience Kubernetes' capabilities without the complexities of a full-scale cluster. It covered the installation process, including necessary prerequisites and step-by-step instructions. Additionally, it provided a practical example of creating a pod, demonstrating the power of container orchestration.🚀 This hands-on approach serves as a user-friendly entry point into the world of Kubernetes, enabling users to explore and experiment in a simplified, local environment. 🌟

Let's Connect:

| ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄|
------- Let's connect! -------
|_____________|
............... \ (•◡•) / ...................
................. \ ...... / .....................
.................. ——- .......................
.................. | ... | ......................
.................. |_ . |_ ....................

Linkedin

GitHub

Twitter

Hashnode

Thank you for exploring my blog! Your interest is truly appreciated. 🙌