This project showcases how to apply essential DevOps practices to turn a simple Flask web application into a live production-ready state. It demonstrates the use of CI/CD pipelines for both code and infrastructure deployment using GitHub Actions.
The primary goal of this project is to automate the deployment and management of a Flask application on an AWS EKS cluster using best practices. The project is divided into two main components:
-
CI/CD Pipeline for Code Deployment:
- Automatically triggers on code changes.
- Builds a Docker image.
- Runs unit tests.
- Deploys the application to the EKS cluster if tests pass.
- Sends notifications to a Discord channel if tests fail.
-
Infrastructure Deployment Pipeline:
- Provisions an AWS EKS cluster using Terraform.
- Installs NGINX Ingress, Prometheus, Grafana, and Loki on the EKS cluster using Helm.
- Uses HashiCorp Cloud for remote state management.
-
Monitoring and Logging
-
Prometheus: Collects real-time metrics.
-
Grafana: Visualizes the metrics collected by Prometheus and Loki.
-
Loki: Aggregates and centralizes logs from the application and Kubernetes cluster.
-
- Automated Infrastructure Provisioning: The pipeline uses Terraform to provision AWS resources and set up an EKS cluster with the necessary tools and services.
- CI/CD Pipelines: The code is built, tested, and deployed using GitHub Actions.
- Monitoring and Logging: Prometheus and Grafana are set up for monitoring, while Loki is configured for logging.
- Discord Notifications: The pipeline is integrated with Discord to send alerts and notifications.
Before you begin, ensure you have the following tools installed and configured on your local machine:
Additionally, ensure you have the following environment variables configured in your GitHub repository secrets:
AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYDISCORD_WEBHOOK_URLTF_API_TOKENDOCKER_USERNAMEDOCKER_PASSWORD
-
Clone the repository:
git clone https://github.com/AB-Rhman/flask-full-workflow.git cd flask-full-workflow -
Set up your AWS CLI and configure it:
aws configure
-
Ensure all required dependencies are installed by checking the codebase.
-
Run the Infrastructure Pipeline:
- Trigger the GitHub Actions pipeline to provision the EKS cluster and install NGINX Ingress, Prometheus, Grafana, and Loki.
-
Connect to Your EKS Cluster:
- After the infrastructure is up, connect your local machine to the EKS cluster:
aws eks update-kubeconfig --region us-east-1 --name demo-eks
- After the infrastructure is up, connect your local machine to the EKS cluster:
-
Access Grafana:
-
Before deploying your application, connect to Grafana to configure Loki as a data source:
kubectl port-forward --namespace monitoring service/prometheus-grafana 3000:80
-
Open Grafana in your browser at
http://localhost:3000and log in. -
Some dashboards form Grafana
-
-
Deploy Your Application:
- Once the infrastructure is up and configured, trigger the pipeline to deploy your application to the EKS cluster.
- Flask: The web framework used to develop the application.
- GitHub Actions: CI/CD pipelines.
- Terraform: Infrastructure as code for provisioning AWS resources.
- Helm: Kubernetes package manager for deploying Prometheus, Grafana, and Loki.
- Prometheus: Monitoring system.
- Grafana: Dashboard for visualizing metrics and logs.
- Loki: Log aggregation system.
- AWS EKS: Managed Kubernetes service.
- HashiCorp Cloud: Remote state management for Terraform.
- NGINX Ingress: Ingress controller for Kubernetes.
Contributions are welcome! Please fork the repository and submit a pull request for any enhancements, bug fixes, or additional features.
For any inquiries or issues, feel free to open an issue on GitHub or contact the project maintainer.


