This project implements a containerized multi-service application extended with a CI/CD pipeline. It includes an API Gateway, monitoring, and a test-driven development approach. Both services are written in different languages to demonstrate the capabilities of microservices.
- Service 1: Provides container-specific data and integrates with Service 2. Written in Python.
- Service 2: Operates privately within the Docker network, supplying data to Service 1. Written in Ruby.
- API Gateway:
- Extended NGINX, functioning as a reverse proxy, load balancer, and API Gateway.
- Exposes REST APIs for system state management and monitoring.
- Container Information:
- IP Address
- Running Processes (
ps -ax) - Available Disk Space (
df -h) - Uptime (
uptime -p)
- System States:
INIT: Resets application to default state.RUNNING: Processes requests normally.PAUSED: Suspends request handling.SHUTDOWN: Stops all containers.
- API Endpoints:
PUT /state: Transition system state.GET /state: Retrieve current state.GET /request: Perform load-balanced service requests.GET /run-log: Fetch state change logs.
- Monitoring:
- Displays service start time and request count since startup.
- Web Interface:
- Allows users to make the API calls on a GUI
- GitLab CI:
- Configured with
.gitlab-ci.ymlfor Build, Test, and Deploy stages.
- Configured with
- Test-Driven Development:
- Tests implemented prior to feature development.
- Tests stored in
tests/directory.
- Pipeline Execution:
- Automatically builds and deploys upon code pushes.
- Static analysis tool -
pylint. - Deployment to a virtual machine for external testing.
- Docker and Docker Compose installed.
- GitLab Runner registered and configured (if testing CI/CD pipeline)
- Tools like
curlorPostmanfor testing API endpoints. - Basic knowledge of CI/CD workflows and Docker.
-
Clone the repository:
git clone -b project https://github.com/zedithx/contdevdep-ex cd contdevdep-ex -
Build and start containers:
docker-compose build --no-cache docker-compose up -d
-
Using the WebUI
-
Open up the webpage served by Nginx on localhost:8197
-
Enter the authentication details based on the login.txt
-
You can now test the request button which will populate the text area with service 1 & service 2 response
-
You can also test the stop button which stops all containers
-
These requests to service1 are handled in a round robin fashion by the nginx server as a load balancer
-
Calling the endpoints
Note: Running in test environment to test locally
Run this command instead. It saves data to a temporary volume instead.
docker-compose -f docker-compose.test.yml up -d
pytestPlease view the end report in the repository for more information and learning points