Skip to content

Latest commit

 

History

13 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mini Flask App Deployment on Kubernetes

A step-by-step guide for running a Flask web application containerized with Docker and deployed on Kubernetes.


Table of Contents

  1. Project Overview
  2. Prerequisites
  3. Project Structure
  4. Setup and Run Locally
  5. Dockerization
  6. Kubernetes Deployment
  7. Accessing the App
  8. Next Steps / Enhancements
  9. License

Project Overview

This project demonstrates how to:

  • Develop a simple Flask web app
  • Containerize it using Docker
  • Deploy it to a Kubernetes cluster (Minikube / EKS / GKE)
  • Make it production-ready with Gunicorn

Prerequisites

Make sure you have the following installed:

Optional:

  • Helm for advanced deployment
  • GitHub / Docker Hub account for pushing images

Project Structure

mini-flask-app/
├── application.py      # Flask app
├── templates/
│   └── index.html      # HTML page rendered by Flask
├── requirements.txt    # Python dependencies
├── Dockerfile          # Container definition
└── README.md

Setup and Run Locally

  1. Create a virtual environment (optional):
python -m venv venv
source venv/bin/activate  # Linux/Mac
venv\Scripts\activate     # Windows
  1. Install dependencies:
pip install -r requirements.txt
  1. Run the Flask app:
python application.py

Visit: http://127.0.0.1:5000


Dockerization

  1. Build Docker image:
docker build -t mini_app:v1.0 .
Screenshot from 2025-11-19 10-34-48
  1. Test locally:
docker run -p 5000:5000 mini_app:v1.0
  1. Push to Docker Hub:
docker tag mini_app:v1.0 <dockerhub-username>/mini_app:v1.0
docker push <dockerhub-username>/mini_app:v1.0
Screenshot from 2025-11-19 10-54-17

Kubernetes Deployment

  1. Start Minikube:
minikube start
Screenshot from 2025-11-19 11-41-23
  1. Create a deployment:
kubectl create deployment miniapp --image=<dockerhub-username>/mini_app:v1.0
  1. Expose the deployment:
kubectl expose deployment miniapp --type=NodePort --port=5000
  1. Check pods:
kubectl get pods
Screenshot from 2025-11-19 11-27-57
  1. Get service info:
kubectl get svc miniapp
  1. Access the app:
  • For Minikube:
minikube service miniapp
Screenshot from 2025-11-19 11-40-26
  • Or open in browser:
http://<minikube-ip>:<nodeport>

Accessing the App

  • Pod IPs are internal and not accessible from outside the cluster.
  • Use NodePort or Ingress to access externally.
  • Example NodePort URL: http://192.168.49.2:32698

Next Steps / Enhancements

  • Add liveness and readiness probes for health checks
  • Implement Ingress + TLS for domain access
  • Automate deployment using CI/CD pipelines (GitHub Actions / ArgoCD)
  • Scale horizontally using replicas

License

This project is open-source and free to use under the MIT License.


About

This is a workflow for creating a minimal application and then making a docker image for it, there after deploying it on kubernetes

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages