Skip to content

hrshtmlng/flask-devops-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Flask DevOps App πŸš€

An end-to-end DevOps project built using Flask, Docker, Kubernetes (Minikube), Nginx, MySQL, and a GitHub Actions CI/CD pipeline.


Project Overview

This project demonstrates a complete DevOps workflow from local development to containerization and orchestration.

The application is containerized using Docker, deployed on Kubernetes (Minikube), connected to a MySQL database running in a separate pod, and exposed via a Kubernetes service.

It also includes a simple UI for user registration and login.


Tech Stack

  • Python Flask
  • Docker
  • Kubernetes (Minikube)
  • MySQL
  • Nginx
  • GitHub Actions
  • Linux (Ubuntu)

Project Architecture

Client β†’ Flask App (Pod) β†’ MySQL (Pod)
            ↓
     Kubernetes Service

Features

  • User Registration
  • User Login (with password hashing)
  • Fetch all users
  • Flask-based UI (Signup/Login)
  • MySQL database integration
  • Dockerized application
  • Kubernetes deployment (multi-pod setup)
  • CI/CD pipeline using GitHub Actions

Folder Structure

.
β”œβ”€β”€ .github/workflows
β”‚   └── ci.yml
β”œβ”€β”€ nginx
β”‚   └── nginx.conf
β”œβ”€β”€ templates
β”‚   └── index.html
β”œβ”€β”€ screenshots
β”œβ”€β”€ app.py
β”œβ”€β”€ deployment.yaml
β”œβ”€β”€ mysql.yaml
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ requirements.txt
└── README.md

Local Setup (Kubernetes)

1. Start Minikube

minikube start

2. Use Minikube Docker

eval $(minikube docker-env)

3. Build Docker Image

docker build -t flask-devops-app .

4. Deploy MySQL

kubectl apply -f mysql.yaml

5. Deploy Flask App

kubectl apply -f deployment.yaml

6. Access Application

minikube service flask-app

API Endpoints

Register

POST /register

Login

POST /login

Get Users

GET /users


Database Setup

If the table does not exist, create it manually:

USE flask_app;

CREATE TABLE users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(100),
    email VARCHAR(100) UNIQUE,
    password TEXT
);

CI/CD Pipeline

GitHub Actions CI/CD automatically:

  • Builds the Docker image
  • Verifies the project setup
  • Runs on every push to the main branch

Workflow file: .github/workflows/ci.yml


Docker (Optional - Local Development)

docker compose up --build

Important Commands

Check Pods

kubectl get pods

View Logs

kubectl logs <pod-name>

Restart Deployment

kubectl rollout restart deployment flask-app

How Project looks?

UI Signup Page

Flask app UI signup page

Shows the Flask application signup screen used for user registration.

API Working

API working response screenshot

Demonstrates the application API responding successfully to requests.

Kubernetes Pods

Kubernetes pod status screenshot

Displays deployed Kubernetes pods for the Flask app and MySQL database.

MySQL Database Data

MySQL database data screenshot

Shows stored user data in the MySQL database.


Learning Outcomes

  • Docker containerization
  • Kubernetes deployment and services
  • Multi-pod architecture
  • Backend ↔ Database integration
  • CI/CD basics with GitHub Actions
  • Debugging real-world deployment issues
  • Linux + terminal workflow

Future Improvements

  • Move credentials to Kubernetes Secrets
  • Add JWT authentication
  • Add HTTPS (SSL)
  • Production setup using Gunicorn + Nginx
  • CI/CD auto-deploy to cloud (AWS/GCP)

Author

Harshit Malang

About

Basic Flask DevOps project with Docker, Nginx and MySQL

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors