Skip to content

sanskar-devops2620/devops-assignment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DevOps Assignment

Project Overview

This project demonstrates a comprehensive DevOps pipeline including CI/CD using GitHub Actions, Docker containerization, cloud deployment on AWS, and real-time monitoring with Prometheus. The application is a simple Flask-based REST API that provides user information and is monitored using Prometheus.

Folder Structure

.
├── ci-cd
│   └── github-actions.yml          # GitHub Actions for CI/CD
├── cloud-deployment
│   └── aws
│       ├── command.txt             # Terraform deployment commands
│       ├── main.tf                 # AWS resource definitions
│       ├── outputs.tf              # Terraform output variables
│       └── variables.tf            # Terraform input variables
├── docker-compose.yml              # Docker Compose configuration
├── Dockerfile                      # Docker image definition
├── prometheus
│   └── prometheus.yml              # Prometheus configuration
├── scripts
│   ├── build.sh                    # Docker image build script
│   ├── deploy.sh                   # Terraform deployment script
│   ├── docker_deploy.sh            # Docker Compose deployment script
│   └── test.sh                     # Test execution script
├── src
│   ├── app.py                      # Flask application
│   ├── models.py                   # Data model definitions
│   ├── routes.py                   # API route handlers
│   └── utils.py                    # Utility functions
└── tests
    └── test_app.py                 # Unit tests

Prerequisites

  • Docker
  • Docker Compose
  • Terraform
  • AWS CLI configured with proper access
  • Python 3.9

Installation & Setup

  1. Clone the repository:

    git clone https://github.com/yourusername/devops-assignment.git
    cd devops-assignment
  2. Install required Python packages:

    pip install -r requirements.txt

Running the Application (Locally)

python src/app.py

Access the application at: http://localhost:5000

Running with Docker Compose

docker-compose up --build -d

Access the application at: http://localhost:5000 Access Prometheus at: http://localhost:9090

Prometheus Monitoring

  • Prometheus metrics are exposed at http://localhost:8000/metrics
  • Access Prometheus dashboard: http://localhost:9090

CI/CD Pipeline (GitHub Actions)

  • CI/CD is triggered on every push or pull request to the main branch.

  • Pipeline stages:

    • Build: Builds and pushes the Docker image.
    • Test: Runs unit tests.
    • Deploy: Deploys to AWS using Terraform.

AWS Deployment using Terraform

  1. Initialize Terraform:

    terraform init
  2. Deploy the infrastructure:

    ./scripts/deploy.sh
  3. Check the public IP of the deployed instance:

    terraform output instance_public_ip

Testing

Run the test suite:

./scripts/test.sh

Usage and Endpoints

  • Home: GET /
  • List Users: GET /users
  • User Details: GET /users/<user_id>

Troubleshooting

  • Check Docker logs:

    docker logs <container_name>
  • Restart Docker Compose:

    docker-compose restart
  • Check Prometheus metrics:

    curl http://localhost:8000/metrics

Contributing

Feel free to submit issues and feature requests. Pull requests are welcome.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors