Skip to content

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🐳🚀 Mini Kubernetes Project – Flask Greeting App

Docker Kubernetes Minikube Flask Postman


✨ Overview

This project demonstrates how to build and containerize a Flask app, push the Docker image to Docker Hub, create a Kubernetes Deployment and Service, and deploy the application on a Minikube cluster. You will also learn how to verify your deployment using the Kubernetes Dashboard and test the application’s performance with Postman.

🖥️ Project Screenshots

Kubernetes Dashboard Flask App UI Postman Load Test
Kubernetes Dashboard Flask App Postman

🛠️ Step-by-Step Guide

Below are all commands you need to recreate the project.


1️⃣ Start Minikube

minikube start --driver=docker

Ensure Docker Desktop is running.


2️⃣ Build Docker Image

Create a Dockerfile:

FROM python:3.9
WORKDIR /app
COPY . .
RUN pip install -r requirements.txt
EXPOSE 5000
CMD ["python", "app.py"]

Build and tag:

docker build -t addusername/myapp:latest .

3️⃣ Push Image to Docker Hub

Login to Docker:

docker login

Push:

docker push addusername/myapp:latest

4️⃣ Create Kubernetes Deployment YAML

apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp
spec:
  replicas: 2
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
    spec:
      containers:
      - name: flask-app
        image: addusername/myapp:latest
        imagePullPolicy: Always
        ports:
        - containerPort: 5000
---
apiVersion: v1
kind: Service
metadata:
  name: myapp-service
spec:
  selector:
    app: myapp
  type: NodePort
  ports:
  - port: 8080
    targetPort: 5000
    nodePort: 30036

Apply:

kubectl apply -f deployment.yaml

5️⃣ Verify Pods & Services

kubectl get pods
kubectl get services

6️⃣ Access the App

Get the Minikube IP:

minikube ip

Visit:

http://<minikube-ip>:30036

✅ You should see the Flask app greet you.


7️⃣ Kubernetes Dashboard

Launch dashboard:

minikube dashboard

8️⃣ Load Testing via Postman

✅ Collection and results are shown in the Postman screenshot above.


📂 Folder Structure

.
├── app.py
├── Dockerfile
├── requirements.txt
└── deployment.yaml

🎯 How to Run Again

Delete old deployments:

kubectl delete deployment myapp
kubectl delete service myapp-service

Re-apply YAML:

kubectl apply -f deployment.yaml

Restart Minikube:

minikube stop
minikube start

🖼️ Image References

For better documentation, upload your screenshots here and replace URLs:


🙌 Credits

Built with ❤️ by Harshit Rai

About

This project shows how to containerize a simple Flask app, deploy it on a Minikube Kubernetes cluster, and test it using Kubernetes Dashboard and Postman.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages