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

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

k8s Cluster with Nginx

ยท

5 min read

๐Ÿ”ถ What is minikube?

Minikube is an open-source tool that facilitates the sektup and management of a single-node Kubernetes cluster for local development and testing purposes.

It is designed to make it easy for developers to run Kubernetes on their local machines, allowing them to experiment with Kubernetes features, develop and test applications, and gain familiarity with Kubernetes without the need for a full-scale multi-node cluster.

๐Ÿ”ถ Features of minikube

(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:

1.Install minikube on your local

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

  • 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 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"

Check above image โฌ†๏ธ 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

Step 8: Stop Minikube

When you are done, you can stop the Minikube cluster with:

minikube stop

Optional: Delete Minikube Cluster

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

minikube delete

That's it! You've successfully installed Minikube on Ubuntu, and you can now start deploying Kubernetes applications for development and testing.

Let's understand the concept pod

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.

Task-02:

Create your first pod on Kubernetes through minikube.

To create your first pod on Kubernetes through Minikube, follow these steps:

  1. Install Minikube: If you haven't already, install Minikube, which is a tool that lets you run a single-node Kubernetes cluster on your machine.

  2. Start Minikube: Open your terminal and start Minikube by running the following command:

 minikube start
  1. Create a Pod Configuration File: Create a YAML configuration file that defines your pod. For example, create a file named my-pod.yaml with the following content:

      apiVersion: v1
      kind: Pod
      metadata:
        name: my-pod
      spec:
        containers:
        - name: my-container
          image: nginx
    

    In this example, the configuration creates a pod named my-pod with a single container running the nginx image.

  2. Apply the Configuration: Apply the pod configuration using the following command:

      kubectl apply -f my-pod.yaml
    
  3. Check the Pod: Verify that the pod is running using the following command:

      kubectl get pods
    

  4. You should see the my-pod pod listed with a status of "Running."

  5. Access the Pod: To fetch a list of all pods, We can also use different flags with the kubectl get pods -o wide command to filter the results or get more detailed information about the pods and the nodes on which they are running. This command will display a table with an additional column showing any labels associated with each pod. Run the following command:

      kubectl get all -o wide
    

That's it! We've created your first pod on Kubernetes through Minikube. This example demonstrates the basic steps of defining a pod configuration, applying it, and accessing the pod.

Happy Learning :)

If you find my blog valuable, I invite you to like, share, and join the discussion. Your feedback is immensely cherished as it fuels continuous improvement. Let's embark on this transformative DevOps adventure together! ๐Ÿš€ #devops #90daysofdevop #git&github #jenkins #k8s

ย