Skip to content

gourabpal04/aks-argocd-voting-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

28 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

DevOps Project: 3-Tier Microservice Voting App

🎯 Project Overview

This project demonstrates a production-ready 3-tier microservice-based Voting App deployed using Azure DevOps CI/CD pipelines, Azure Kubernetes Service (AKS), and ArgoCD GitOps workflows. It showcases modern DevOps practices including containerization, microservices architecture, continuous integration/deployment, and GitOps.

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    3-Tier Microservice Architecture                 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Tier 1: Presentation Layer (Frontend)                              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚  React.js Application                                        β”‚   β”‚
β”‚  β”‚  β€’ Modern UI with Tailwind CSS                               β”‚   β”‚
β”‚  β”‚  β€’ Responsive design                                         β”‚   β”‚
β”‚  β”‚  β€’ Real-time results                                         β”‚   β”‚
β”‚  β”‚  β€’ Vote casting interface                                    β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Tier 2: Application Layer (Backend)                                β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚  FastAPI Backend Service                                     β”‚   β”‚
β”‚  β”‚  β€’ RESTful API endpoints                                     β”‚   β”‚
β”‚  β”‚  β€’ Vote processing logic                                     β”‚   β”‚
β”‚  β”‚  β€’ Data validation                                           β”‚   β”‚
β”‚  β”‚  β€’ Authentication & authorization                            β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Tier 3: Data Layer (Database)                                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚  MongoDB Database                                            β”‚   β”‚
β”‚  β”‚  β€’ Poll storage                                              β”‚   β”‚
β”‚  β”‚  β€’ Vote records                                              β”‚   β”‚
β”‚  β”‚  β€’ User sessions                                             β”‚   β”‚
β”‚  β”‚  β€’ Real-time aggregation                                     β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Features

Application Features

  • Create Polls: Interactive poll creation with multiple options
  • Cast Votes: Secure voting system with IP-based validation
  • Real-time Results: Live vote counting and percentage calculations
  • Responsive Design: Mobile-first UI with Tailwind CSS
  • Poll Management: Create, view, and manage polls

DevOps Features

  • Containerization: Docker containers for each service
  • Microservices: Independent, scalable services
  • CI/CD Pipelines: Azure DevOps automated pipelines
  • GitOps: ArgoCD for continuous deployment
  • Infrastructure as Code: Kubernetes manifests
  • Monitoring: Health checks and observability
  • Security: Container scanning and security policies

πŸ› οΈ Technology Stack

Layer Technology Purpose
Frontend React.js, Tailwind CSS User interface and experience
Backend FastAPI, Python API services and business logic
Database MongoDB Data persistence and storage
Container Docker Application containerization
Orchestration Kubernetes (AKS) Container orchestration
CI/CD Azure DevOps Continuous integration/deployment
GitOps ArgoCD Declarative deployment
Monitoring Prometheus, Grafana Observability and metrics

πŸ“ Project Structure

aks-argocd-voting-app/
β”œβ”€β”€ frontend/                   # React application (Tier 1)
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/         # React components
β”‚   β”‚   β”œβ”€β”€ pages/              # Application pages
β”‚   β”‚   └── services/           # API services
β”‚   β”œβ”€β”€ Dockerfile             # Frontend container
β”‚   └── package.json           # Dependencies
β”œβ”€β”€ backend/                   # FastAPI application (Tier 2)
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ models/            # Data models
β”‚   β”‚   β”œβ”€β”€ routes/            # API routes
β”‚   β”‚   └── main.py            # Application entry
β”‚   β”œβ”€β”€ Dockerfile             # Backend container
β”‚   └── requirements.txt       # Python dependencies
β”œβ”€β”€ database/                  # MongoDB configuration (Tier 3)
β”‚   └── init.js               # Database initialization
β”œβ”€β”€ k8s/                      # Kubernetes manifests
β”‚   └── base/                 # Base configurations
β”‚       β”œβ”€β”€ namespace.yaml    # Namespace definition
β”‚       β”œβ”€β”€ mongo.yaml        # Database deployment
β”‚       β”œβ”€β”€ backend.yaml      # Backend deployment
β”‚       β”œβ”€β”€ frontend.yaml     # Frontend deployment
β”‚       └── ingress.yaml      # Load balancer
β”œβ”€β”€ argocd/                   # ArgoCD GitOps
β”‚   β”œβ”€β”€ project.yaml          # ArgoCD project
β”‚   └── app.yaml              # Application definition
β”œβ”€β”€ .azure-pipelines/         # CI/CD pipelines
β”‚   β”œβ”€β”€ frontend-pipeline.yml # Frontend pipeline
β”‚   β”œβ”€β”€ backend-pipeline.yml  # Backend pipeline
β”‚   └── shared-steps.yml      # Shared pipeline steps
β”œβ”€β”€ scripts/                  # Deployment scripts
β”‚   β”œβ”€β”€ deploy-local.sh       # Local deployment
β”‚   └── k8s-deploy.sh         # Kubernetes deployment
β”œβ”€β”€ docker-compose.yml        # Local development
└── README.md                 # This file

πŸš€ Quick Start

Prerequisites

  • Docker & Docker Compose
  • Node.js 18+ (for local development)
  • Python 3.11+ (for local development)
  • kubectl (for Kubernetes deployment)
  • Azure CLI (for AKS deployment)

Local Development

  1. Clone the repository

    git clone https://github.com/your-org/aks-argocd-voting-app.git
    cd aks-argocd-voting-app
  2. Start with Docker Compose

    chmod +x scripts/deploy-local.sh
    ./scripts/deploy-local.sh up
  3. Access the application

  4. View logs

    ./scripts/deploy-local.sh logs

Kubernetes Deployment

  1. Deploy to Kubernetes

    chmod +x scripts/k8s-deploy.sh
    ./scripts/k8s-deploy.sh deploy
  2. Setup ArgoCD

    ./scripts/k8s-deploy.sh argocd
  3. Check deployment status

    ./scripts/k8s-deploy.sh status

πŸ”„ CI/CD Pipeline

Azure DevOps Pipeline Features

  • Frontend Pipeline (frontend-pipeline.yml)

    • Code linting and testing
    • Docker image build and push
    • Kubernetes deployment
    • Health checks
  • Backend Pipeline (backend-pipeline.yml)

    • Code quality checks (Black, Flake8)
    • Security scanning (Bandit, Safety)
    • Unit and integration tests
    • Docker image build and push
    • Database migrations
    • API health checks

Pipeline Stages

  1. Build & Test

    • Code quality checks
    • Security scans
    • Unit tests
    • Container image build
  2. Deploy

    • Kubernetes deployment
    • GitOps sync
    • Health verification
  3. Post-Deploy

    • Integration tests
    • Performance tests
    • Notifications

πŸ”§ GitOps with ArgoCD

ArgoCD Configuration

  • Project: voting-app-project - Defines access controls and policies
  • Application: voting-app - Manages the deployment lifecycle
  • Sync Policy: Automated sync with self-healing enabled
  • Health Checks: Custom health checks for all services

Deployment Flow

  1. Code changes pushed to Git
  2. Azure DevOps builds and pushes container images
  3. Pipeline updates Kubernetes manifests
  4. ArgoCD detects changes and syncs
  5. Application deployed to AKS

πŸ“Š Monitoring & Observability

Health Checks

  • Frontend: HTTP health endpoint
  • Backend: /api/health endpoint with database connectivity
  • Database: MongoDB ping command

Metrics & Monitoring

  • Kubernetes resource metrics
  • Application performance metrics
  • Custom business metrics (votes, polls)
  • Log aggregation and analysis

πŸ”’ Security

Container Security

  • Non-root user containers
  • Security scanning with Trivy/Aqua
  • Minimal base images
  • Regular updates

Kubernetes Security

  • Network policies
  • Pod security policies
  • RBAC (Role-Based Access Control)
  • Secrets management

Application Security

  • Input validation
  • SQL injection prevention
  • XSS protection
  • CORS configuration

🎯 DevOps Best Practices Demonstrated

  1. Infrastructure as Code: All infrastructure defined in code
  2. GitOps: Declarative deployments with ArgoCD
  3. Microservices: Loosely coupled, independently deployable services
  4. Continuous Integration: Automated testing and builds
  5. Continuous Deployment: Automated deployments with rollback capability
  6. Monitoring: Comprehensive observability and alerting
  7. Security: Security scanning and best practices
  8. Scalability: Horizontal pod autoscaling

πŸš€ Deployment Scenarios

Scenario 1: Local Development

# Start local environment
./scripts/deploy-local.sh up

# View logs
./scripts/deploy-local.sh logs

# Stop services
./scripts/deploy-local.sh down

Scenario 2: Kubernetes Cluster

# Deploy to K8s
./scripts/k8s-deploy.sh deploy

# Setup ArgoCD
./scripts/k8s-deploy.sh argocd

# Check status
./scripts/k8s-deploy.sh status

Scenario 3: Azure Kubernetes Service (AKS)

# Create AKS cluster
az aks create --resource-group voting-app-rg --name voting-app-aks

# Get credentials
az aks get-credentials --resource-group voting-app-rg --name voting-app-aks

# Deploy application
./scripts/k8s-deploy.sh deploy

πŸ§ͺ Testing

Local Testing

# Backend tests
cd backend
python -m pytest

# Frontend tests
cd frontend
npm test

# Integration tests
./scripts/test-integration.sh

Production Testing

  • Health check endpoints
  • Load testing with k6
  • End-to-end testing
  • Performance monitoring

πŸ“ˆ Scaling

Horizontal Pod Autoscaling

# HPA configuration included in manifests
minReplicas: 2
maxReplicas: 10
targetCPUUtilizationPercentage: 70

Manual Scaling

# Scale frontend
./scripts/k8s-deploy.sh scale frontend 5

# Scale backend
./scripts/k8s-deploy.sh scale backend 3

πŸ”§ Troubleshooting

Common Issues

  1. Port conflicts: Ensure ports 3000, 8001, 27017 are available
  2. Docker issues: Restart Docker daemon
  3. Kubernetes connectivity: Check kubectl configuration
  4. Service health: Use health check endpoints

Debug Commands

# Check pod logs
kubectl logs -f deployment/backend -n voting-app

# Execute into pod
kubectl exec -it deployment/backend -n voting-app -- /bin/bash

# Port forward for debugging
kubectl port-forward svc/backend-service 8001:8001 -n voting-app

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/new-feature)
  3. Commit changes (git commit -am 'Add new feature')
  4. Push to branch (git push origin feature/new-feature)
  5. Create a Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ“ž Support

πŸ™ Acknowledgments

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors