Day 31 Task: Launching your First Kubernetes Cluster with Nginx running

Day 31 Task: Launching your First Kubernetes Cluster with Nginx running

Awesome! You learned the architecture of one of the most important tools "Kubernetes" in your previous task.

What about doing some hands-on now?

  • Let's read about minikube and implement k8s in our local machine
  1. What is minikube?

Ans:- Minikube is a tool that quickly sets up a local Kubernetes cluster on macOS, Linux, and Windows. It can deploy as a VM, a container, or on bare metal.

Minikube is a pared-down version of Kubernetes that gives you all the benefits of Kubernetes with a lot less effort.

This makes it an interesting option for users who are new to containers, and also for projects in the world of edge computing and the Internet of Things.

  1. Features of minikube

Ans:-

(a) Supports the latest Kubernetes release (+6 previous minor versions)

(b) Cross-platform (Linux, macOS, Windows)

(c) Deploy as a VM, a container, or on bare-metal

(d) Multiple container runtimes (CRI-O, containerd, docker)

(e) Direct API endpoint for blazing-fast image load and build

(f) Advanced features such as LoadBalancer, filesystem mounts, FeatureGates, and network policy

(g) Addons for easily installed Kubernetes applications

(h) Supports common CI environments

Task-01:

Install minikube on your local

  • For installation, you can Visit this page or you can follow this ⬇️

Minikube Installation Guide for Ubuntu

This guide provides step-by-step instructions for installing Minikube on Ubuntu. Minikube allows you to run a single-node Kubernetes cluster locally for development and testing purposes.

Pre-requisites

  • Ubuntu OS

  • sudo privileges

  • Internet access

  • Instance t2.medium

  • Virtualization support enabled (Check with egrep -c '(vmx|svm)' /proc/cpuinfo, 0=disabled 1=enabled)

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
  • Add current user to docker group (To use docker without root)
sudo usermod -aG docker $USER && newgrp docker
  • Now, logout (use the sudo reboot 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 6: Start Minikube

  • Now, you can start Minikube with the following command:
minikube start --driver=docker

Step 7: Check Cluster Status

  • Check the cluster status with:
minikube status
  • You can also use kubectl to interact with your cluster:
sudo snap install kubectl --classic
kubectl get nodes

Let's understand the concept pod

Ans:-

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

A Pod (as in a pod of whales or pea pod) is a group of one or more containers, with shared storage and network resources, and a specification for how to run the containers. A Pod's contents are always co-located and co-scheduled, and run in a shared context. A Pod models an application-specific "logical host": it contains one or more application containers which are relatively tightly coupled.

You can read more about pod from here .

Task-02:

Create your first pod on Kubernetes through minikube.

Step 1: Create a file pod.yaml and paste the code :

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

Step 2: Now to check if the pod is created or not, use kubectl apply -f pod.yaml , kubectl get pods and kubectl get pods -o wide for a detailed view.

Step 3: you can see our pod is running on IP : 10.244.0.3

Step 4: Let's see if, we have to go inside the Kubernetes cluster, minikube makes this quick easy, just type minikube ssh to get inside and then use curl to get the data from the IP

Step 5: After that use this command

curl -L http://10.244.0.3:80

Step 5: You can see now that nginx is running inside the pod ⬆️


Happy Learning

Thanks For Reading! :)

-Sriparthu💝💥