Skip to content

Maintains deployment workflows, infrastructure definitions, and operational tools.

Notifications You must be signed in to change notification settings

SWEProject25/devops

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

153 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Hankers DevOps

Hankers Logo

Production Infrastructure & Deployment Platform

Enterprise-grade DevOps infrastructure for the Hankers social network

πŸ”— Live Platform: hankers.tech

πŸ“Œ Overview

Hankers DevOps is a production-ready infrastructure platform built with Infrastructure as Code (IaC) principles, designed for scalability, reliability, and automation. The project implements modern DevOps practices including container orchestration, CI/CD pipelines, monitoring, and cost-optimized cloud infrastructure.

This codebase demonstrates real-world DevOps engineering: automated deployments, infrastructure versioning, zero-downtime releases, and comprehensive observability.


✨ Key Infrastructure Features

  • πŸš€ CI/CD Automation β€” GitHub Actions for build, test, and deploy
  • ☸️ Kubernetes Orchestration β€” Azure Kubernetes Service (AKS) for container management
  • πŸ“¦ GitOps Deployment β€” ArgoCD for declarative continuous delivery
  • 🎯 Auto-scaling β€” Karpenter for intelligent node provisioning
  • πŸ“Š Full Observability β€” Prometheus, Grafana, Loki for metrics and logs
  • πŸ”’ Automated SSL/TLS β€” cert-manager with Let's Encrypt
  • πŸ—οΈ Infrastructure as Code β€” Terraform for reproducible infrastructure
  • 🐳 Container Registry β€” GitHub Container Registry (GHCR) + Docker Hub
  • πŸ’Ύ Managed Database β€” PostgreSQL on Azure with automated backups
  • πŸ—„οΈ Caching Layer β€” Redis cluster for session management
  • πŸ“¦ Object Storage β€” Azure Blob Storage with CloudFront CDN
  • πŸ” Security First β€” Network policies, RBAC, encrypted storage

πŸ—οΈ Architecture Overview

High-Level Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         Internet Traffic                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
                           β–Ό
                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                   β”‚ Load Balancer β”‚
                   β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
                           β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚   Nginx Ingress        β”‚
              β”‚   (SSL Termination)    β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚             β”‚             β”‚
         β–Ό             β–Ό             β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚Frontend β”‚   β”‚ Backend β”‚   β”‚   AI    β”‚
   β”‚  Pods   β”‚   β”‚  Pods   β”‚   β”‚  Bot    β”‚
   β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜
        β”‚             β”‚             β”‚
        β”‚             β–Ό             β”‚
        β”‚      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
        β”‚      β”‚  PostgreSQL  β”‚    β”‚
        β”‚      β”‚   (Azure)    β”‚    β”‚
        β”‚      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
        β”‚                          β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚
                   β–Ό
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚    Redis    β”‚
            β”‚   Cluster   β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Deployment Pipeline Flow

Developer Push β†’ GitHub β†’ CI/CD Pipeline β†’ Docker Build β†’ Push to Registry
                                                                 β”‚
                                                                 β–Ό
                                                      Update Helm Charts
                                                                 β”‚
                                                                 β–Ό
                                                        ArgoCD Detects Change
                                                                 β”‚
                                                                 β–Ό
                                                    Deploy to Kubernetes (30s)
                                                                 β”‚
                                                                 β–Ό
                                                      Discord Notification

πŸ›  Technology Stack

Infrastructure & Orchestration

  • Cloud Provider: Microsoft Azure
  • Container Orchestration: Azure Kubernetes Service (AKS)
  • Infrastructure as Code: Terraform
  • Package Management: Helm
  • GitOps: ArgoCD

CI/CD & Automation

  • CI/CD Platform: GitHub Actions
  • Container Registry: GitHub Container Registry (GHCR), Docker Hub
  • Configuration Management: Ansible
  • Build Tools: Docker, multi-stage builds

Monitoring & Observability

  • Metrics: Prometheus
  • Visualization: Grafana
  • Log Aggregation: Loki
  • Log Shipping: Promtail
  • Alerting: AlertManager

Networking & Security

  • Ingress Controller: Nginx Ingress
  • Certificate Management: cert-manager
  • SSL Provider: Let's Encrypt
  • DNS Management: Azure DNS / Route53

Data Layer

  • Primary Database: PostgreSQL (Azure Database)
  • Cache/Sessions: Redis (Kubernetes-managed)
  • Object Storage: Azure Blob Storage
  • CDN: CloudFront

Auto-scaling & Cost Optimization

  • Node Auto-scaling: Karpenter
  • Pod Auto-scaling: Horizontal Pod Autoscaler (HPA)
  • Spot Instances: Enabled for 50%+ cost savings

🎯 Design Patterns & Best Practices

1. Factory Pattern

  • Location: CI/CD pipeline (runner/.github/workflows/cicd-pipeline.yml)
  • Implementation: Universal pipeline dynamically selects build scripts based on repository
  • Benefit: Single workflow handles backend, frontend, and cross-platform projects

2. Strategy Pattern

  • Location: Deployment scripts (devops/*/deploy.sh)
  • Implementation: Different Helm values files (dev/prod) selected at runtime
  • Benefit: Environment-specific configurations without code duplication

3. Template Method Pattern

  • Location: Helm charts (*/helm-chart/templates/)
  • Implementation: Base Kubernetes manifests with variable substitution
  • Benefit: DRY principle, reusable templates across services

4. Builder Pattern

  • Location: Terraform modules (infra/terraform-prod/modules/)
  • Implementation: Composable infrastructure blocks (VPC, EKS, RDS)
  • Benefit: Testable, reusable infrastructure components

5. Decorator Pattern

  • Location: Docker multi-stage builds
  • Implementation: Layered approach (base β†’ build β†’ runtime)
  • Benefit: Smaller images, better caching, production security

6. Observer Pattern

  • Location: Monitoring stack
  • Implementation: Prometheus scrapes metrics, AlertManager triggers notifications
  • Benefit: Decoupled monitoring, scalable alerting

7. Proxy Pattern

  • Location: Nginx Ingress Controller
  • Implementation: Reverse proxy routing external traffic to internal services
  • Benefit: Centralized SSL, load balancing, single entry point

8. Repository Pattern

  • Location: Multi-repo structure
  • Implementation: Separate repos for backend, frontend, cross-platform, devops
  • Benefit: Independent versioning, team autonomy, clear boundaries

πŸš€ Quick Start

Prerequisites

  • Azure subscription (or AWS for alternative setup)
  • kubectl, helm, terraform installed locally
  • GitHub account with Personal Access Token (PAT)
  • Docker installed for local testing

Infrastructure Setup

# 1. Clone the repository
git clone https://github.com/SWEProject25/devops.git
cd devops

# 2. Configure Terraform variables
cd infra/terraform
cp terraform.tfvars.example terraform.tfvars
# Edit terraform.tfvars with your values

# 3. Provision infrastructure
terraform init
terraform plan
terraform apply

# 4. Configure kubectl
aws eks update-kubeconfig --region us-east-1 --name hankers-eks

# 5. Install Kubernetes components using Ansible
cd ../setup/ansible
ansible-playbook playbook.yml

# 6. Verify deployment
kubectl get pods -A

Manual Deployment (Optional)

# Deploy a specific service manually
cd backend  # or frontend, ml-model-service
bash deploy.sh

πŸ“ Project Structure

devops/
β”œβ”€β”€ backend/                    # Backend service deployment
β”‚   β”œβ”€β”€ helm-chart/            # Kubernetes manifests
β”‚   β”œβ”€β”€ build.sh               # Docker build script
β”‚   β”œβ”€β”€ deploy.sh              # Helm deployment script
β”‚   └── sonar-project.properties
β”œβ”€β”€ frontend/                   # Frontend service deployment
β”‚   β”œβ”€β”€ helm-chart/
β”‚   β”œβ”€β”€ build.sh
β”‚   β”œβ”€β”€ deploy.sh
β”‚   └── sonar-project.properties
β”œβ”€β”€ cross-platform/            # Flutter mobile app builds
β”‚   β”œβ”€β”€ build.sh
β”‚   └── sonar-project.properties
β”œβ”€β”€ ml-model-service/          # AI service deployment
β”‚   β”œβ”€β”€ build.sh
β”‚   └── deploy.sh
β”œβ”€β”€ ai-bot/                    # AI bot service
β”‚   └── build.sh
β”œβ”€β”€ infra/
β”‚   β”œβ”€β”€ terraform/             # Infrastructure as Code
β”‚   β”‚   β”œβ”€β”€ main.tf
β”‚   β”‚   β”œβ”€β”€ modules/          # Reusable Terraform modules
β”‚   β”‚   β”‚   β”œβ”€β”€ vpc/
β”‚   β”‚   β”‚   β”œβ”€β”€ eks/
β”‚   β”‚   β”‚   β”œβ”€β”€ rds/
β”‚   β”‚   β”‚   β”œβ”€β”€ s3/
β”‚   β”‚   β”‚   β”œβ”€β”€ karpenter/
β”‚   β”‚   β”‚   └── cloudfront/
β”‚   β”‚   β”œβ”€β”€ outputs.tf
β”‚   β”‚   └── variables.tf
β”‚   └── setup/
β”‚       β”œβ”€β”€ ansible/           # Kubernetes setup automation
β”‚       β”‚   β”œβ”€β”€ playbook.yml
β”‚       β”‚   β”œβ”€β”€ roles/        # Ansible roles for each component
β”‚       β”‚   β”‚   β”œβ”€β”€ helm_repos/
β”‚       β”‚   β”‚   β”œβ”€β”€ metrics-server/
β”‚       β”‚   β”‚   β”œβ”€β”€ ingress/
β”‚       β”‚   β”‚   β”œβ”€β”€ cert_manager/
β”‚       β”‚   β”‚   β”œβ”€β”€ redis/
β”‚       β”‚   β”‚   β”œβ”€β”€ monitoring/
β”‚       β”‚   β”‚   β”œβ”€β”€ logging/
β”‚       β”‚   β”‚   β”œβ”€β”€ karpenter/
β”‚       β”‚   β”‚   └── argocd/
β”‚       β”‚   └── inventory/
β”‚       └── config/            # Configuration files
β”‚           β”œβ”€β”€ argocd/
β”‚           β”œβ”€β”€ ingress/
β”‚           β”œβ”€β”€ karpenter/
β”‚           β”œβ”€β”€ monitoring/
β”‚           └── logging/
└── README.md

πŸ”§ Configuration Management

Environment Variables

Each service requires specific environment variables. These are managed through:

  1. GitHub Secrets β€” Sensitive credentials (API keys, passwords)
  2. Helm Values β€” Service configurations (values.yaml)
  3. ConfigMaps β€” Non-sensitive application configs
  4. Secrets β€” Encrypted sensitive data in Kubernetes

Key Configuration Files

  • terraform.tfvars β€” Infrastructure parameters
  • values.yaml β€” Helm chart configurations
  • sonar-project.properties β€” Code quality settings
  • ansible.cfg β€” Automation configuration

πŸ“Š Monitoring & Observability

Access Monitoring Dashboards

Available Dashboards

  1. Kubernetes Cluster Overview β€” CPU, memory, pods, nodes
  2. Node Exporter β€” Detailed node metrics
  3. Application Metrics β€” Custom service metrics
  4. Log Exploration β€” Loki integration for log analysis

Alerting

AlertManager configured for:

  • High CPU/memory usage
  • Pod crash loops
  • Certificate expiration warnings
  • Database connection issues

πŸ” Security Features

  • βœ… Network Policies β€” Pod-to-pod traffic control
  • βœ… RBAC β€” Role-based access control for Kubernetes
  • βœ… Encrypted Storage β€” All persistent volumes encrypted
  • βœ… SSL/TLS β€” Automatic certificate management
  • βœ… Secret Management β€” Kubernetes secrets for credentials
  • βœ… Security Scanning β€” Container image vulnerability scanning
  • βœ… Pod Security Standards β€” Enforced security policies

πŸ’° Cost Optimization

Implemented Strategies

  1. Karpenter Auto-scaling β€” Intelligent node provisioning
  2. Spot Instances β€” 50-70% cost reduction for non-critical workloads
  3. Right-sizing β€” Automated resource optimization
  4. No NAT Gateway β€” Saved $45/month by using public subnets
  5. ARM Instances β€” 20% cheaper than x86 (t4g vs t3)
  6. Storage Optimization β€” gp3 volumes instead of gp2
  7. Reduced Backup Retention β€” 1 day instead of 7 for non-prod

Estimated Monthly Costs

  • Kubernetes Cluster: ~$70-100
  • Database (RDS): ~$15-30
  • Load Balancer: ~$20
  • Storage: ~$10
  • Monitoring: ~$5
  • Total: ~$120-165/month

🚦 CI/CD Pipeline

Pipeline Stages

  1. Code Checkout β€” Pull latest code from repository
  2. Run Tests β€” Unit tests, integration tests, coverage
  3. Build Docker Image β€” Multi-stage builds for optimization
  4. Push to Registry β€” GHCR and Docker Hub
  5. Update Helm Charts β€” Automated version bump
  6. ArgoCD Sync β€” Automatic deployment (30 seconds)
  7. Notify Team β€” Discord webhook notification

Deployment Speed

  • Build Time: ~3-5 minutes
  • Deployment Time: ~30 seconds (ArgoCD)
  • Total Time to Production: ~5 minutes

πŸ“š Documentation

Quick Links


πŸŽ“ DevOps Team


Karim Farid

πŸ“„ License

This project is for educational and portfolio purposes. All tools used are open-source with commercial-friendly licenses:

  • Kubernetes, Docker, Helm, Terraform: Apache 2.0 License βœ…
  • Prometheus: Apache 2.0 License βœ…
  • Grafana, Loki: AGPL v3 (acceptable for internal use) βœ…
  • GitHub Actions: Free tier for private repos βœ…

🀝 Contributing

This is a production infrastructure repository. For collaboration or questions:

  1. Open an issue for discussion
  2. Submit pull requests with detailed descriptions
  3. Follow infrastructure best practices
  4. Test changes in a separate environment first

πŸ“ž Support

For infrastructure issues or questions:


🌟 Acknowledgments

Special thanks to the open-source community for the amazing tools that make this infrastructure possible:

  • Kubernetes community
  • HashiCorp (Terraform)
  • Helm maintainers
  • Prometheus & Grafana teams
  • cert-manager contributors
  • Karpenter developers

⭐ If you find this DevOps setup useful, consider starring the repository!

About

Maintains deployment workflows, infrastructure definitions, and operational tools.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors