Skip to content

abhishektang/elevate-learning-k8s

Repository files navigation

πŸŽ“ Elevate Learning - Cloud-Native LMS on Kubernetes

Django Kubernetes MySQL License

A production-ready Learning Management System (LMS) deployed on Kubernetes with comprehensive orchestration features including self-healing, auto-scaling, zero-downtime deployments, and load balancing.

🌟 Features

  • πŸ” User Management: Role-based access control (Admin, Educator, Learner)
  • πŸ“š Course Management: Create, update, archive courses with rich content
  • πŸ“Š Progress Tracking: Automated learner progress monitoring
  • πŸŽ–οΈ Certificate Generation: Automatic digital certificates on completion
  • πŸ“± QR Code Integration: Quick course access via mobile devices
  • πŸ’¬ Social Learning: Comments and interactions on courses
  • πŸ”„ Zero-Downtime Deployments: Rolling updates with Kubernetes
  • ⚑ Auto-Scaling: Dynamic scaling based on load
  • πŸ›‘οΈ Self-Healing: Automatic pod recovery and health checks

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     Load Balancer                        β”‚
β”‚                  (NodePort: 30080)                       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚                β”‚                β”‚
   β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”
   β”‚  Nginx   β”‚    β”‚  Django  β”‚    β”‚  Django  β”‚
   β”‚  Proxy   β”‚    β”‚  Web-1   β”‚    β”‚  Web-2   β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜
                         β”‚                β”‚
                    β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”
                    β”‚       MySQL 8.0          β”‚
                    β”‚    (Persistent Volume)    β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Technology Stack

Component Technology Version
Framework Django 5.1.7
Database MySQL 8.0
Web Server Nginx 1.29.3
Container Runtime containerd 2.1.4
Orchestration K3s v1.33.5
OS Ubuntu 22.04 LTS

πŸ“‹ Prerequisites

  • 3 Linux VMs (1 master + 2 workers)
    • Master: 2 vCPU, 4GB RAM
    • Workers: 2 vCPU, 2GB RAM each
  • Ubuntu 22.04 LTS or later
  • Static IP addresses for external access
  • SSH access to all nodes
  • Docker (for image building)

πŸš€ Quick Start

1️⃣ Clone the Repository

git clone https://github.com/abhishektang/elevate-learning-k8s.git
cd elevate-learning-k8s

2️⃣ Deploy K3s Cluster

On Master Node:

cd All_mds
chmod +x install-k3s-master.sh
sudo ./install-k3s-master.sh

On Each Worker Node:

# Copy token from master: sudo cat /var/lib/rancher/k3s/server/node-token
chmod +x install-k3s-worker.sh
# Edit script with your master IP and token
sudo ./install-k3s-worker.sh

3️⃣ Build and Deploy Application

# Build Docker image
cd elevatelearning
docker build -t elevatelearning-web:latest .

# Import to K3s
sudo k3s ctr images import elevatelearning-web.tar

# Deploy to Kubernetes
cd k8s
kubectl apply -f namespace.yaml
kubectl apply -f configmap.yaml
kubectl apply -f mysql-deployment.yaml
kubectl apply -f django-deployment.yaml
kubectl apply -f nginx-deployment.yaml

4️⃣ Access the Application

http://<MASTER_IP>:30080/elevatelearning/home/

Default Admin Credentials:

  • Username: admin
  • Password: admin123

πŸ§ͺ Orchestration Tests

Run comprehensive tests to verify Kubernetes orchestration features:

chmod +x run-orchestration-tests.sh
./run-orchestration-tests.sh

Tests Included:

  • βœ… Self-Healing: Automatic pod recovery
  • βœ… Load Balancing: Traffic distribution across pods
  • βœ… Auto-Scaling: Dynamic replica management (3β†’5β†’3)
  • βœ… Rolling Updates: Zero-downtime deployments
  • βœ… Rollback: Instant recovery to previous versions

Expected output: 5/5 tests passed ✨

πŸ“ Project Structure

elevate-learning-k8s/
β”œβ”€β”€ elevatelearning/              # Django application
β”‚   β”œβ”€β”€ elevatelearning/          # Project settings
β”‚   β”œβ”€β”€ elevatelearningapp/       # Main app (views, models, URLs)
β”‚   β”œβ”€β”€ templates/                # HTML templates
β”‚   β”œβ”€β”€ k8s/                      # Kubernetes manifests
β”‚   β”‚   β”œβ”€β”€ namespace.yaml
β”‚   β”‚   β”œβ”€β”€ configmap.yaml
β”‚   β”‚   β”œβ”€β”€ mysql-deployment.yaml
β”‚   β”‚   β”œβ”€β”€ django-deployment.yaml
β”‚   β”‚   └── nginx-deployment.yaml
β”‚   β”œβ”€β”€ Dockerfile                # Container image definition
β”‚   β”œβ”€β”€ requirements.txt          # Python dependencies
β”‚   β”œβ”€β”€ entrypoint.sh            # Container startup script
β”‚   └── nginx.conf               # Nginx reverse proxy config
β”œβ”€β”€ All_mds/                      # Documentation & scripts
β”‚   β”œβ”€β”€ install-k3s-master.sh    # Master node setup
β”‚   β”œβ”€β”€ install-k3s-worker.sh    # Worker node setup
β”‚   β”œβ”€β”€ deploy-to-k8s.sh         # Deployment automation
β”‚   β”œβ”€β”€ K3S_SETUP_GUIDE.md       # Cluster setup guide
β”‚   β”œβ”€β”€ DEPLOYMENT.md            # Deployment instructions
β”‚   β”œβ”€β”€ ARCHITECTURE.md          # Architecture documentation
β”‚   └── PROJECT_PROPOSAL.md      # Project overview
β”œβ”€β”€ run-orchestration-tests.sh   # Automated test suite
β”œβ”€β”€ ORCHESTRATION_TEST_SCRIPT_README.md
β”œβ”€β”€ QUICK_START_TESTS.md
β”œβ”€β”€ .gitignore                   # Git ignore rules
└── README.md                    # This file

πŸ”§ Configuration

Environment Variables (ConfigMap)

Key configurations in k8s/configmap.yaml:

CSRF_TRUSTED_ORIGINS: "http://<YOUR_IP>:30080"
ALLOWED_HOSTS: "*"
DB_HOST: "mysql-service"
DB_NAME: "elevatelearning_db"
DB_USER: "djangouser"
DEBUG: "False"

Kubernetes Resources

Resource Replicas CPU Memory
Django 3 250m-500m 512Mi-1Gi
MySQL 1 - 2Gi
Nginx 1 - 256Mi

πŸ” Security

  • βœ… CSRF Protection: Token-based form validation
  • βœ… Secret Management: Kubernetes secrets for sensitive data
  • βœ… Role-Based Access: Admin, Educator, Learner roles
  • βœ… Network Policies: Pod-to-pod communication restrictions
  • βœ… Security Headers: X-Frame-Options, CSP, HSTS

⚠️ Important: Never commit:

  • SSH private keys
  • Database passwords
  • Django SECRET_KEY
  • .env files

All sensitive files are excluded via .gitignore.

πŸ“Š Monitoring & Health

Health Check Endpoints:

  • Liveness Probe: /elevatelearning/home/
  • Readiness Probe: /elevatelearning/home/

Check Cluster Status:

kubectl get nodes -o wide
kubectl get pods -n elevatelearning -o wide
kubectl get services -n elevatelearning

🌐 Multi-Cloud Deployment

This project is cloud-agnostic and can be deployed on:

  • βœ… GCP - Compute Engine VMs
  • βœ… AWS - EC2 instances with EKS or K3s
  • βœ… Azure - Azure VMs with AKS or K3s
  • βœ… On-Premises - Any Linux infrastructure

See documentation for migration guides.

πŸ“š Documentation

🀝 Contributing

This is an academic project, but suggestions are welcome!

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

πŸ“ License

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

Support

For issues or questions:

  1. Check the documentation
  2. Review troubleshooting guides
  3. Open an issue on GitHub

⭐ Star this repo if you find it helpful! ⭐

Built with ❀️ using Django, Kubernetes, and Cloud Native technologies.

About

πŸŽ“ Production-ready Learning Management System deployed on Kubernetes with Django, MySQL, and Nginx. Features self-healing, auto-scaling, zero-downtime deployments, and comprehensive orchestration capabilities.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors