Day 31: Launching your First Kubernetes Cluster with Nginx running

Moiz AsifMoiz Asif
4 min read

Welcome to blog post on hands-on learning with Kubernetes! In our previous blog #Day30, we explored the architecture of this powerful tool, and now it's time to take our knowledge to the next level.

What is Minikube?

Minikube is a lightweight, open-source tool designed for developers and DevOps engineers to run a single-node Kubernetes cluster on their local machine. It's perfect for testing and developing Kubernetes applications without the need for a full-scale cluster. Minikube provides a quick and easy way to get hands-on experience with Kubernetes.

Features of Minikube:

Minikube comes with several features that make it a popular choice for developers looking to set up and run Kubernetes clusters locally. Here are some key features of Minikube:

  1. Local Kubernetes Cluster: Minikube allows you to run a single-node Kubernetes cluster on your local machine.

  2. Cross-Platform Support: Minikube is designed to work on different operating systems, including Linux, macOS, and Windows. It achieves this by leveraging virtualization technologies such as VirtualBox, VMware, Hyper-V, and others.

  3. Easy Setup: Minikube aims to be easy to install and configure. It provides a simple command-line interface that allows you to start and stop the local Kubernetes cluster with minimal effort.

  4. Cluster Version Management: Minikube supports different versions of Kubernetes, enabling you to test your applications on specific Kubernetes versions.

  5. kubectl Integration: Minikube seamlessly integrates with kubectl, the Kubernetes command-line tool. This means that you can use standard kubectl commands to interact with and manage your Minikube cluster.

  6. Add-ons and Configuration Options: Minikube supports various add-ons and configuration options that enable you to customize your local Kubernetes cluster. Add-ons include features like the Kubernetes Dashboard, Ingress controllers, and more.

  7. Network and Storage Configuration: Minikube provides options to configure the networking and storage aspects of the local cluster. This allows developers to simulate different network and storage scenarios and test their applications accordingly.

Install Minikube on AWS EC2 Ubuntu?

This guide provides step-by-step instructions for installing Minikube on AWS EC2 Ubuntu.

Pre-requisites

  • 2 CPUs or more

  • 2GB of free memory

  • 20GB of free disk space

  • Internet connection

  • Container or virtual machine manager, such as Docker, QEMU, Hyperkit, Hyper-V, KVM, Parallels, Podman, VirtualBox, or VMware Fusion/Workstation

Task-01

Minikube Installation

  • Create an EC2 instance as suggested above

Step 1: Update System Packages

Update your package lists to make sure you are getting the latest version and dependencies.

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

Start and enable Docker.

sudo systemctl enable --now docker

Now you can see Docker is running

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

sudo usermod -aG docker $USER && newgrp docker

Now, logout (use exit command) and connect again.

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

Check the cluster status with:

minikube status

You can also use kubectl to interact with your cluster:

kubectl get nodes

Task-02

Create your first pod on Kubernetes through minikube.

But first, let's discuss about what are pods?

Pods are the smallest deployable units of computing that you can create and manage in Kubernetes

It is a group of one or more containers that are deployed together on the same host which shares storage, and network resources, and a specification for how to run the containers.

To create a pod we need to create a yaml file. Here we are going to create a pod of nginx

 apiVersion: v1
 kind: Pod
 metadata:
   name: nginx-pod
 spec:
   containers:
   - name: nginx
     image: nginx:1.14.2
     ports:
     - containerPort: 80

Apply the configuration using the kubectl command:

kubectl apply -f pod.yml

To access the Nginx Pod, run the following command to access the Minikube VM:

 minikube ssh

Once inside the Minikube VM, you can use curl to access the Pod's IP address. Replace <pod_ip_address> with the actual IP address of your Pod.

 curl <pod_ip_address>

In my case the IP is curl 10.244.0.3

These are the steps we follow to install Minikube and create pods using Kubernetes CLI. Hope this article helped you to understand the basics.

Thank you for reading this Blog!

0
Subscribe to my newsletter

Read articles from Moiz Asif directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Moiz Asif
Moiz Asif