Day 31 : Easy Steps to Launch a Kubernetes Cluster and Install Nginx

Day 31 : Easy Steps to Launch a Kubernetes Cluster and Install Nginx

Setting Up Kubernetes Locally with Minikube

Minikube is a great tool for anyone wanting to learn Kubernetes. It lets us set up a local Kubernetes cluster, making it perfect for learning, testing, and development.

What is Minikube?🧊

Minikube is a lightweight version of Kubernetes that lets us run a Kubernetes cluster on our local machine. It works on macOS, Linux, and Windows, and provides all the features of a full Kubernetes cluster in a simpler and faster setup.

Key Features:

  1. Cross-Platform: Works on Linux, macOS, and Windows.

  2. Multiple Container Runtimes: Supports containerd, CRI-O, and Docker.

  3. Direct API Endpoints: Allows quick image loads and builds.

  4. Advanced Features: LoadBalancer, filesystem mounts, network policy.

  5. Addons: Easily install Kubernetes applications like dashboards and metrics servers.

  6. Supports common CI environments

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

Let's understand the concept pod📚

In Kubernetes, Pods are the smallest units we can deploy. They contain one or more containers that share network and storage resources. A pod can run a single container, but more complex apps can run multiple containers within the same pod. Essentially, a Pod is a group of containers that share storage and network resources and have a plan for how to run them. The containers in a Pod always run together in the same context, acting as a "logical host" for our application.

Task-01: Install Minikube on Our Local Machine💻

➤To install Minikube, please refer to the official Minikube Installation Documentation

➤After the installation, let's start Minikube.

minikube start

➤check the minikube status

minikube status

➤minikube is running

➤We can also start minikube from Docker.

Task-02: Create the first pod on Kubernetes through Minikube.📟

➤create yaml file for nginx

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

➤Apply the configuration to create the pod:

kubectl apply -f pod.yaml

➤Verify that the pod is running:

kubectl get pods

➤To access the nginx pod, we can forward the port:

kubectl port-forward nginx 8080:80

➤Visit http://localhost:8080 in our browser to see the nginx welcome page.

➤To stop the container, use the following command:

minikube stop

Conclusion📝

Kubernetes has changed container management by offering a strong platform for deploying, scaling, and managing containerized apps, making it essential in DevOps. Minikube provides an easy way to try out Kubernetes locally, helping developers and engineers learn and test Kubernetes features like Pods and deployments. By working with Minikube, we've started our journey to mastering Kubernetes, which will help us build and manage scalable, reliable apps in real-world settings.