Skip to content

atulkamble/minikube-nginx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Minikube + NGINX Deployment Guide

Deploying & Exposing NGINX on Local Kubernetes (Minikube Lab)

This document provides a structured, step-by-step guide to deploy an NGINX application on a local Kubernetes cluster using Minikube and expose it through a Kubernetes Service.


🧰 1️⃣ Prerequisites

Ensure the following tools are installed and running:

  • βœ… Docker Desktop (running in background)
  • βœ… Minikube
  • βœ… kubectl
  • βœ… Stable Internet connection
  • βœ… Basic understanding of Kubernetes YAML files

Verify installations:

minikube version
kubectl version --client
docker --version

🏁 2️⃣ Start Minikube Cluster

Start your local Kubernetes cluster:

minikube start
minikube status

Verify cluster node:

kubectl get nodes

Expected Output:

NAME       STATUS   ROLES           AGE   VERSION
minikube   Ready    control-plane   ...

βš™οΈ 3️⃣ (Optional) Enable Useful Addons

List available addons:

minikube addons list

Enable Metrics Server (for monitoring):

minikube addons enable metrics-server

Open Kubernetes Dashboard:

minikube dashboard

πŸ“ 4️⃣ Create Project Directory

mkdir minikube-nginx
cd minikube-nginx

πŸ“ 5️⃣ Create Deployment YAML

Create file:

touch deployment.yaml

πŸ“„ deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: access-app-deployment
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx-container
        image: nginx:latest
        ports:
        - containerPort: 80

Apply Deployment

kubectl apply -f deployment.yaml

Verify:

kubectl get deployments
kubectl get pods

🌐 6️⃣ Create Service YAML (Expose Application)

Create file:

touch service.yaml

πŸ“„ service.yaml

apiVersion: v1
kind: Service
metadata:
  name: access-app-service
spec:
  selector:
    app: nginx
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
  type: NodePort

Apply Service

kubectl apply -f service.yaml

Verify:

kubectl get services

🌍 7️⃣ Access Application

Option 1: Using Minikube Service (Recommended)

minikube service access-app-service

This will automatically open the NGINX application in your browser.


Option 2: If Service Type is LoadBalancer

For LoadBalancer support in Minikube:

minikube tunnel

Keep this running in a separate terminal.


πŸ“ˆ 8️⃣ Scaling the Application

Update replicas in deployment.yaml:

replicas: 5

Apply changes:

kubectl apply -f deployment.yaml

Verify:

kubectl get pods

You should now see 5 running pods.


πŸ“Š 9️⃣ Monitoring & Resource Usage

After enabling metrics-server:

kubectl top nodes
kubectl top pods

πŸ”„ 1️⃣0️⃣ Common kubectl Commands

kubectl get all
kubectl describe pod <pod-name>
kubectl logs <pod-name>
kubectl delete -f deployment.yaml
kubectl delete -f service.yaml

☁️ Deploying on Azure Kubernetes Service (AKS)

On AKS, expose deployment using LoadBalancer:

kubectl expose deployment access-app-deployment \
  --name=access-app-service \
  --type=LoadBalancer \
  --port=80 \
  --target-port=80

Then check external IP:

kubectl get services

πŸ§ͺ Lab Validation Checklist

βœ” Minikube started βœ” Deployment created βœ” Pods running βœ” Service exposed βœ” Application accessible in browser βœ” Scaling verified βœ” Monitoring enabled


πŸ“Œ Summary

This lab demonstrated:

  • Kubernetes Deployment creation
  • Replica management
  • Service exposure (NodePort / LoadBalancer)
  • Local cluster management with Minikube
  • Basic monitoring using metrics-server

About

Minikube Project runnning nginx container

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages