A Python-based microservice application for converting MP4 videos to MP3 audio files, deployed on AWS Elastic Kubernetes Service (EKS).
This project demonstrates a microservices architecture with four main components:
- Auth Server: Handles user authentication and authorization
- Converter Module: Processes video-to-audio conversion tasks
- Database Server: PostgreSQL and MongoDB for data persistence
- Notification Server: Sends email notifications and handles two-factor authentication (2FA)
- Prerequisites
- Deployment Overview
- AWS EKS Setup
- Database Deployment
- Microservices Deployment
- Configuration
- API Documentation
- Cleanup
Before you begin, ensure you have the following installed and configured:
-
AWS Account: Create an AWS account if you don't have one. Follow the AWS setup guide.
-
Helm: Kubernetes package manager. Install from the official Helm documentation.
-
Python: Required for local development. Download from the official Python website.
-
AWS CLI: Install the AWS Command Line Interface from the official installation guide.
-
kubectl: Kubernetes command-line tool. Install the latest stable version from the Kubernetes documentation.
-
Database Access: Ensure you have access to set up PostgreSQL and MongoDB instances.
The deployment process follows these high-level steps:
- AWS EKS Cluster Setup: Create and configure the EKS cluster with appropriate IAM roles and node groups
- Database Deployment: Deploy MongoDB and PostgreSQL using Helm charts
- Message Queue Setup: Deploy RabbitMQ and create required queues
- Microservices Deployment: Deploy all four microservices (auth, gateway, converter, notification)
- Configuration: Configure email settings and secrets
- Validation: Verify all components are running correctly
-
Follow the steps in the AWS EKS service IAM role documentation using the root user.
-
After creation, your role should look similar to this:
-
Important: Explicitly attach the
AmazonEKS_CNI_Policyif it is not attached by default.
-
Follow the steps in the Amazon EKS node IAM role documentation using the root user.
-
Note: You do NOT need to configure any VPC CNI policy mentioned after step 5.e in the documentation.
-
Attach the following policies to your role (if not attached by default):
AmazonEKS_CNI_PolicyAmazonEBSCSIDriverPolicyAmazonEC2ContainerRegistryReadOnly
-
Your AmazonEKSNodeRole should look similar to this:
- Log in to the AWS Management Console with your AWS account credentials.
- Navigate to the Amazon EKS service from the AWS Console dashboard.
- Click "Create cluster."
- Configure your cluster:
- Choose a name for your cluster
- Configure networking settings (VPC, subnets)
- Select the
eksClusterIAM role created in Step 1
- Review and create the cluster.
- Wait for the cluster to provision (this may take several minutes).
- Once the cluster status shows as "Active," proceed to create node groups.
- In the "Compute" section of your cluster, click "Add node group."
- Configure the node group:
- Choose the AMI (default recommended)
- Select instance type (e.g., t3.medium)
- Set the number of nodes
- Select the
AmazonEKSNodeRolecreated earlier
- Click "Create node group."
Important: Ensure all necessary ports are open in the node security group.
-
Enable the
ebs-csi-driveraddon in your EKS cluster. -
This addon is required for enabling Persistent Volume Claims (PVCs) once the cluster is created.
-
Clone this repository:
git clone <repository-url> cd microservices-python-app-main
-
Set the cluster context:
aws eks update-kubeconfig --name <cluster_name> --region <aws_region>
-
Verify the connection:
kubectl get nodes
-
Navigate to the MongoDB Helm chart directory:
cd Helm_charts/MongoDB -
Edit
values.yamland set your database username and password. -
Install MongoDB:
helm install mongo . -
Wait for MongoDB to be ready:
kubectl get pods -w
-
Connect to MongoDB:
mongosh mongodb://<username>:<pwd>@<nodeip>:30005/mp3s?authSource=admin
-
Navigate to the PostgreSQL Helm chart directory:
cd ../Postgres -
Edit
values.yamland set your database username and password. -
Install PostgreSQL:
helm install postgres . -
Wait for PostgreSQL to be ready:
kubectl get pods -w
-
Connect to PostgreSQL and initialize the database:
psql 'postgres://<username>:<pwd>@<nodeip>:30003/authdb' -
Copy and execute all queries from the
init.sqlfile in the PostgreSQL directory.
-
Navigate to the RabbitMQ Helm chart directory:
cd ../RabbitMQ -
Install RabbitMQ:
helm install rabbitmq . -
Wait for RabbitMQ to be ready:
kubectl get pods -w
-
Access the RabbitMQ management interface:
- Open your browser and navigate to:
http://<nodeIp>:30004 - Use default credentials:
- Username:
guest - Password:
guest
- Username:
- Open your browser and navigate to:
-
Create Required Queues: Before deploying the converter module, create two queues in RabbitMQ:
mp3video
Note: Ensure all necessary ports (30003, 30004, 30005) are open in the node security group.
Deploy each microservice by applying its manifest files:
cd auth-service/manifest
kubectl apply -f .cd gateway-service/manifest
kubectl apply -f .-
Before deploying, configure the email and password in the secret file:
cd converter-service/manifest # Edit secret.yaml with your email and password
-
Apply the manifest:
kubectl apply -f .
-
Configure email settings (see Notification Configuration below).
-
Apply the manifest:
cd notification-service/manifest kubectl apply -f .
To configure email notifications and two-factor authentication (2FA):
- Go to your Gmail account and click on your profile.
- Click on "Manage Your Google Account."
- Navigate to the "Security" tab on the left side panel.
- Enable "2-Step Verification."
- Search for "App passwords" in the settings.
- Click on "Other" and provide a name for this application.
- Click "Generate" and copy the generated password.
- Edit
notification-service/manifest/secret.yamland paste:- Your email address
- The generated app password
After deploying all microservices, verify the status of all components:
kubectl get allCheck that all pods are in the Running state:
kubectl get podsView service endpoints:
kubectl get servicesThe application exposes the following API endpoints through the gateway service (port 30002):
Authenticate and receive a JWT token.
Request:
POST http://<nodeIP>:30002/loginExample using curl:
curl -X POST http://<nodeIP>:30002/login -u <email>:<password>Expected Response: success! (with JWT token)
Upload an MP4 video file for conversion.
Request:
POST http://<nodeIP>:30002/upload
Authorization: Bearer <JWT Token>
Content-Type: multipart/form-dataExample using curl:
curl -X POST \
-F 'file=@./video.mp4' \
-H 'Authorization: Bearer <JWT Token>' \
http://<nodeIP>:30002/uploadExpected Response: A file identifier (fid) will be sent to your email.
Download the converted MP3 file.
Request:
GET http://<nodeIP>:30002/download?fid=<Generated file identifier>
Authorization: Bearer <JWT Token>Example using curl:
curl --output video.mp3 \
-X GET \
-H 'Authorization: Bearer <JWT Token>' \
"http://<nodeIP>:30002/download?fid=<Generated fid>"Expected Response: The MP3 file will be downloaded to your local machine.
To destroy the infrastructure and clean up resources:
-
Delete Microservices:
kubectl delete -f auth-service/manifest/ kubectl delete -f gateway-service/manifest/ kubectl delete -f converter-service/manifest/ kubectl delete -f notification-service/manifest/
-
Uninstall Helm Charts:
helm uninstall mongo helm uninstall postgres helm uninstall rabbitmq
-
Delete Node Group:
- Navigate to your EKS cluster in the AWS Console
- Go to the "Compute" tab
- Select the node group and click "Delete"
-
Delete EKS Cluster:
- Once the node group is deleted, navigate to the cluster overview
- Click "Delete" and confirm the deletion
Note: Ensure all resources are properly cleaned up to avoid unnecessary AWS charges.




