Minikube - Launch First Kubernetes Cluster and Pod

Minikube - Launch First Kubernetes Cluster and Pod

Today, in this blog I am going to guide you on how to launch the Kubernetes cluster on Minikube with Nginx pod using Ubuntu VM.

What is minikube?

  • minikube is a tool that lets you run Kubernetes locally. minikube runs an all-in-one or a multi-node local Kubernetes cluster on your personal computer (including Windows, macOS and Linux PCs) so that you can try out Kubernetes, or for daily development work.

What is kubectl?

  • The Kubernetes command-line tool, kubectl, allows you to run commands against Kubernetes clusters. You can use kubectl to deploy applications, inspect and manage cluster resources, and view logs.

System Specification

  • 2 CPUs or more

  • 2GB of free memory

  • 20GB of free disk space

  • Internet connection

  • Container or virtual machine manager, such as Docker

For this project, I used Ubuntu 22.04 LTS on AWS. You can run this on your local computer whether it is MacOS, Windows or Linux.

Getting Started

Installation

  1. Update System

    • After connecting the system first run update
    sudo apt update

update

  1. Install container manager

    • Here I choose Docker. Run the following command to install Docker
    sudo apt-get install docker.io docker-compose -y

install docker

  1. Install minikube

    • To install Minikube in Linux with an x86-64 system copy and paste the following command
    curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
    sudo install minikube-linux-amd64 /usr/local/bin/minikube
  1. Add docker to the group

    • To minicube work with the docker, the current user needs to be added to the docker group.
    sudo usermod -aG docker $USER && newgrp docker

docker group

  1. Install and Set Up kubectl

    • To interact with the cluster, the kubectl must be installed.

    • If your device hasn't already installed kubectl, you can install it by following the below steps on Linux. For other OS refer to the links: MacOS Windows

    • Download the latest release with the command:

      • x86-64
        curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
  • ARM64
        curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/arm64/kubectl"
  • Install kubectl
    sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
  • Verify installation
    kubectl version --client --output=yaml
  1. Reboot system

     sudo reboot now
    

    reboot

After performing these steps, you are ready to launch the application on Kubernetes.


Create Pod

Start the minikube

minikube start

start minikube

To build a pod, create a pod file with yaml extension.

vim nginx-pod.yml

Copy and paste the below code into the file and save.

apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  containers:
  - name: nginx
    image: nginx:stable-alpine3.17-slim
    ports:
    - containerPort: 80

pod yaml file

Finally, enter the below command to create the pod.

kubectl apply -f nginx-pod.yml

pod create

To verify:

kubectl get pods

pod list

The pod is now created.


Conclusion

In this tutorial, we learned how to create a Kubernetes cluster using minikube. we installed docker for container management and kubectl to access the cluster. Also created a pod with the YAML file on the Linux system.