A fully containerized backend service built with FastAPI that retrieves and serves all records from a single MySQL
table (data).
The project is deployed on OpenShift, using Kubernetes manifests for deployments, persistent storage, and routing.
It demonstrates clean project structure, CI/CD-friendly deployment scripts, and full end-to-end integration between
MySQL and FastAPI.
This project provisions and deploys:
- MySQL database running in OpenShift with persistent volume storage.
- FastAPI backend service that connects to MySQL and exposes a simple GET endpoint to return the entire contents of
the
datatable. - Data Access Layer (DAL) for clean separation between database operations and API logic.
- Publicly accessible Route in OpenShift to retrieve the data from any browser or HTTP client (Postman, curl, etc.).
data-loader/
├── services/
│ └── data_loader/ # Data loading service (DAL, FastAPI app)
├── scripts/ # SQL scripts & OpenShift CLI command scripts
├── infrastructure/
│ └── k8s/ # Kubernetes (OpenShift) YAML manifests
├── Dockerfile # Docker image for FastAPI app
├── test.py # test code to run FastAPI server locally
└── README.md # Project documentation
- FastAPI REST API exposing data from MySQL.
- MySQL deployment on OpenShift with persistent volume claim (PVC).
- Secrets / Environment Variables for secure database connection configuration.
- Clean code architecture with a dedicated Data Access Layer.
- Automated database initialization scripts for table creation and data seeding.
- Dockerized for portability and easy deployment.
- Kubernetes manifests for declarative infrastructure provisioning.
- OpenShift Route for public access to the API.
- Backend Framework: FastAPI
- Database: MySQL 8.x
- Containerization: Docker
- Orchestration: Kubernetes (OpenShift)
- Deployment: OpenShift CLI & YAML manifests
- Language: Python 3.9
Before starting, ensure you have:
- Docker Hub account (for pushing/pulling images).
- OpenShift CLI (
oc) installed and logged in. - Python 3.9+ installed locally for development.
- Docker installed and running.
GET /get-allReturns all rows from the data table in JSON format.
[
{
"id": 1,
"first_name": "John",
"last_name": "Doe"
},
{
"id": 2,
"first_name": "Jane",
"last_name": "Smith"
}
]| Column | Type | Notes |
|---|---|---|
| id | INT | PRIMARY KEY |
| firstName | VARCHAR(50) | NOT NULL |
| lastName | VARCHAR(50) | NOT NULL |
Inside scripts/ you will find:
- commands.bat -> All CLI commands for building, deploying, and configuring the project.
- create_data.sql -> SQL script to create the
datatable. - insert_data.sql -> SQL script to insert sample data.
Once deployed, the OpenShift Route will provide a public URL:
https://<your-app-route>/get-all
Open it in your browser or use:
curl https://<your-app-route>/get-all