A fully automated DevOps pipeline for deploying an email breach checking service to Kubernetes using Docker, GitHub Actions, and Ansible.
This project demonstrates a complete CI/CD pipeline that automatically builds, containerizes, and deploys a Next.js email breach checking application to a K3s cluster using modern DevOps practices.
βββββββββββββββ ββββββββββββββββ βββββββββββββββ ββββββββββββββββ
β GitHub βββββΆβ GitHub βββββΆβ Docker βββββΆβ K3s β
β Repository β β Actions β β Hub β β Cluster β
βββββββββββββββ ββββββββββββββββ βββββββββββββββ ββββββββββββββββ
β β²
βΌ β
ββββββββββββββββ βββββββββββββββ
β Ansible βββββββββββββββββββββββββΆβ Remote β
β Playbook β SSH β Server β
ββββββββββββββββ βββββββββββββββ
- Next.js 14 - React framework with TypeScript
- Tailwind CSS - Utility-first CSS framework
- Lucide React - Beautiful icons
- Theme Support - Light/Dark mode toggle
- Docker - Containerization
- Kubernetes (K3s) - Container orchestration
- GitHub Actions - CI/CD pipeline
- Ansible - Configuration management
- Docker Hub - Container registry
- Horizontal Pod Autoscaler (HPA) - Auto-scaling based on CPU/Memory
- Resource Limits - CPU and memory management
- Health Checks - Readiness and liveness probes
- β Email breach checking functionality
- β Real-time breach status feedback
- β Responsive design
- β Dark/Light theme toggle
- β Clean, modern UI
- β Security-focused email analysis
- π Automated CI/CD Pipeline
- π³ Docker containerization
- βΈοΈ Kubernetes deployment
- π Auto-scaling capabilities
- K3s cluster [light-weight] or Kubernetes cluster
- Docker Hub account
- GitHub repository with secrets configured
- Ansible installed on the deployment machine
DOCKER_USERNAME=my-dockerhub-username
DOCKER_PASSWORD=my-dockerhub-password
K3S_HOST=my-k3s-server-ip
K3S_USER=my-ssh-username
K3S_SSH_PRIVATE_KEY=my-ssh-private-key-
Clone the repository
git clone https://github.com/akash2061/K8s-Project.git cd K8s-Project -
Build and push Docker image
docker build -t akash2061/email-check:latest ./App docker push akash2061/email-check:latest
-
Deploy using Ansible
ansible-playbook -i ansible/inventory.yml ansible/deploy.yml \ -e k3s_host=SERVER_IP \ -e k3s_user=SSH_USER
-
Access the application
http://SERVER_IP:30080
| Resource | Configuration |
|---|---|
| Deployment | 1 replica, rolling updates |
| Service | NodePort (30080) |
| HPA | 1-2 replicas, CPU: 20%, Memory: 50% |
| Resources | Request: 250m CPU, 256Mi RAM |
| Limits | 500m CPU, 512Mi RAM |
The pipeline consists of two main jobs:
-
Build Job
- Checkout code
- Docker login
- Build and push image to Docker Hub
-
Deploy Job
- Install Ansible
- Setup SSH connectivity
- Deploy to K3s using Ansible playbook
- Rolling updates for zero-downtime deployments
- Smart deployment with change detection
- Health checks to ensure successful deployment
- Resource monitoring with HPA status verification
HPA Thresholds:
- CPU: 20% (Testing threshold)
- Memory: 50%
- Min Replicas: 1
- Max Replicas: 2# Check deployment status
kubectl get pods -l app=email-check
# Monitor HPA
kubectl get hpa email-check-hpa
# View service
kubectl get svc email-check-service- Non-root containers - Security best practices
- Resource limits - Prevent resource exhaustion
- SSH key authentication - Secure server access
- Private container registry - Controlled image distribution
- Email breach detection - Core security functionality
K8s-Project/
βββ App/ # Next.js email breach checking app
β βββ components/ # React components
β βββ app/ # App router pages
β βββ Dockerfile # Container configuration
βββ k8s/
β βββ k8s.yml # Kubernetes manifests
βββ ansible/
β βββ deploy.yml # Ansible playbook
β βββ inventory.yml # Ansible inventory
βββ .github/workflows/
β βββ CI_CD_Pipeline.yml # GitHub Actions workflow
βββ README.md # Project documentation
- Code Push β Triggers GitHub Actions
- Build Stage β Docker image creation and push
- Deploy Stage β Ansible deployment to K3s
- Health Check β Verify deployment success
- Monitoring β HPA and resource monitoring
| Metric | Target | Current |
|---|---|---|
| Deployment Time | < 2 minutes | ~1 minute |
| CPU Usage | < 20% | 0% (idle) |
| Memory Usage | < 50% | ~27% |
| Uptime | 99.9% | β |
| Auto-scale Response | < 30s | β |
-
HPA Metrics showing
<unknown># Wait 2-3 minutes for metrics initialization kubectl describe hpa email-check-hpa -
Deployment stuck in pending
kubectl describe pod -l app=email-check
-
Service not accessible
kubectl get svc email-check-service # Check NodePort and firewall rules
# Pod logs
kubectl logs -l app=email-check
# Deployment events
kubectl describe deployment email-check
# Node resources
kubectl top nodes
# Ansible verbose output
ansible-playbook -vvv -i ansible/inventory.yml ansible/deploy.yml- Fork the repository
- Create a feature branch
- Make your changes
- Test the deployment pipeline
- Submit a pull request
This project is open source and available under the MIT License.
Built with β€οΈ using Modern DevOps Practices
Automated β’ Scalable β’ Reliable