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:
Update System Packages:
sudo apt update && sudo apt upgrade -y
Install Required Packages:
sudo apt install -y curl wget apt-transport-https
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
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 :
Install kubectl:
sudo apt install kubectl
Change Permissions & Move :
Start Minikube:
minikube start --driver=docker
check status:
Check Cluster Status:
kubectl cluster-info
Stop Minikube:
minikube stop
Optional: Delete Minikube Cluster
minikube delete
Task 2: Creating Your First Pod on Kubernetes
Create a
k8s
directory:mkdir k8s && cd k8s
Create a
deployment.yml
file:Use your preferred text editor to create the file. For example,
vim deployment.yml
Create Namespace:
Dry run to validate the file:
kubectl apply --dry-run=client -f deployment.yml
Apply
deployment.yml
:kubectl apply -f deployment.yml
Check deployment status:
kubectl get pods -n nginx && kubectl get deployments -n nginx
Create
service.yml
for exposing the container:vim service.yml
Validate through a dry run:
kubectl apply --dry-run=client -f service.yml
Apply
service.yml
:kubectl apply -f service.yml
Check services:
kubectl get services
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!