(day 31-33)Kubernetes Kickstart: Nginx, Deployment, and Beyond!

(day 31-33)Kubernetes Kickstart: Nginx, Deployment, and Beyond!

Introduction: Welcome to day (31-33) of the 90DaysOfDevOps challenge! In this blog post, we'll guide you through the process of setting up your first Kubernetes cluster using Minikube and running Nginx on it. This hands-on tutorial will help you understand the basics of Minikube, Kubernetes, and deploying a simple Nginx service.

Day 31: Getting Started with Minikube

What is Minikube? Minikube is a utility that allows you to run Kubernetes (K8s) on your local machine. It creates a single-node cluster within a virtual machine, providing an environment to practice Kubernetes operations without the need for a full-scale installation.

Task 1: Installing Minikube on Ubuntu

Pre-requisites:

  • Ubuntu OS

  • sudo privileges

  • Internet access

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

Steps:

  1. Update System Packages:

     sudo apt update && sudo apt upgrade -y
    

  2. Install Required Packages:

     sudo apt install -y curl wget apt-transport-https
    

  3. Install Docker:

    • Start and enable Docker.

        sudo systemctl enable --now docker
      
    • Add the current user to the docker group.

        sudo usermod -aG docker $USER && newgrp docker
      
  4. Install Minikube:

     curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube_1.23.2.deb
     sudo dpkg -i minikube_1.23.2.deb
    

    Change Permissions & Move :

  5. Install kubectl:

     sudo apt install kubectl
    

    Change Permissions & Move :

  6. Start Minikube:

     minikube start --driver=docker
    

    check status:

  7. Check Cluster Status:

     kubectl cluster-info
    
  8. Stop Minikube:

    minikube stop
    

Optional: Delete Minikube Cluster

minikube delete

Task 2: Creating Your First Pod on Kubernetes

  1. Create ak8s directory:

     mkdir k8s && cd k8s
    
  2. Create adeployment.yml file:

    • Use your preferred text editor to create the file. For example,

        vim deployment.yml
      

  1. Create Namespace:

  2. Dry run to validate the file:

     kubectl apply --dry-run=client -f deployment.yml
    

  3. Applydeployment.yml:

     kubectl apply -f deployment.yml
    

  4. Check deployment status:

     kubectl get pods -n nginx && kubectl get deployments -n nginx
    

  5. Createservice.yml for exposing the container:

    •     vim service.yml
      
  6. Validate through a dry run:

     kubectl apply --dry-run=client -f service.yml
    

  7. Applyservice.yml:

     kubectl apply -f service.yml
    

  8. Check services:

    kubectl get services
    

  9. Access the Nginx service using Minikube:

    minikube service --url nginx-service -n nginx
    

Conclusion: Congratulations! You've successfully set up your first Kubernetes cluster using Minikube and deployed an Nginx service. This marks a significant milestone in your 90DaysOfDevOps journey. Stay tuned for more exciting challenges and tutorials in the upcoming days. Happy coding!