A comprehensive DevSecOps pipeline for deploying a Netflix-clone application on AWS with integrated security scanning, GitOps, and advanced monitoring.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Git Repository β
β (Source Code + Jenkinsfile) β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββ
β Jenkins CI/CD Pipeline β
β β Checkout Code β
β β SAST (SonarQube/Semgrep) β
β β Secret Scanning β
β β Dependency Check β
β β Build & Unit Tests β
ββββββββββββββ¬ββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββ
β Docker Build & Security β
β β Docker Build β
β β Trivy Scan β
β β Grype Scan β
β β Push to ECR β
ββββββββββββββ¬ββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββ
β ArgoCD GitOps Deployment β
β β Auto-Sync from Git β
β β Kustomize Overlays β
β β Multi-Environment Support β
ββββββββββββββ¬ββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββ
β AWS EKS Kubernetes Cluster β
β β Rolling Updates β
β β Auto-Scaling (HPA) β
β β Network Policies β
β β Pod Security Policies β
ββββββββββββββ¬ββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββ
β Monitoring & Observability β
β β Prometheus Metrics β
β β Grafana Dashboards β
β β Alertmanager Notifications β
β β ELK Stack Logging β
β β Jaeger Distributed Tracing β
ββββββββββββββββββββββββββββββββββ
- File:
Dockerfile - Multi-stage build for optimization
- Non-root user for security
- Health checks enabled
- Layer caching optimized
- File:
Jenkinsfile - Parallel execution of security scans
- Quality gates (SonarQube)
- Automated testing
- Docker image building & scanning
- ECR push automation
- GitOps trigger
Key Stages:
Checkout β Code Quality β Build β Security Scanning β
Docker Build β Image Scanning β Push to ECR β GitOps Deploy β Smoke Tests
- SonarQube: SAST (Static Application Security Testing)
- Trivy: Container vulnerability scanning
- Grype: Software vulnerability scanner
- Semgrep: Code pattern analysis
- TruffleHog: Secret detection
- OWASP Dependency-Check: Dependency vulnerabilities
- File:
k8s-deployment.yaml - Security Context hardened
- Resource limits enforced
- Health checks (liveness, readiness, startup)
- Horizontal Pod Autoscaler (HPA)
- Pod Disruption Budget (PDB)
- Network Policies
- Rolling Updates
- File:
argocd-applicationset.yaml - Declarative continuous delivery
- Multi-environment support
- Kustomize overlays
- Auto-sync enabled
- Self-healing capabilities
- Slack notifications
- File:
prometheus-setup.yaml - Service monitoring via ServiceMonitor
- Recording rules for performance
- Alerting rules with thresholds
- 15-day data retention
- Alertmanager integration
Key Metrics:
- Request rate & latency
- Error rates
- Pod restart counters
- Resource usage (CPU/Memory)
- Deployment status
- File:
grafana-setup.yaml - Pre-built dashboards
- Real-time monitoring
- Alert visualization
- Multi-datasource support
- HTTPS enabled
# 1. Start entire stack
docker-compose up -d
# 2. Access services
echo "Netflix App: http://localhost:3000"
echo "Jenkins: http://localhost:8080"
echo "Prometheus: http://localhost:9090"
echo "Grafana: http://localhost:3001 (admin/admin)"
echo "Kibana: http://localhost:5601"
echo "SonarQube: http://localhost:9000"
echo "Jaeger: http://localhost:16686"
# 3. View application logs
docker logs netflix-clone
# 4. Run security scans
docker-compose exec app npm run security-check# 1. Make setup script executable
chmod +x setup-devsecops-pipeline.sh
# 2. Configure AWS credentials
export AWS_REGION="us-east-1"
export AWS_ACCOUNT_ID="123456789"
# 3. Run setup
./setup-devsecops-pipeline.sh
# 4. Verify deployment
kubectl get pods -n production
kubectl port-forward svc/netflix-clone 8080:80 -n productionβ
Non-root user execution
β
Read-only root filesystem
β
No privilege escalation
β
Dropped unnecessary capabilities
β
Security scanning on build
β
Network Policies (ingress/egress)
β
Pod Security Policies
β
RBAC (Role-Based Access Control)
β
Resource quotas & limits
β
Security context hardened
β
SAST analysis (SonarQube)
β
Dependency scanning (OWASP)
β
Secret detection (TruffleHog)
β
Container scanning (Trivy/Grype)
β
Code quality gates enforced
β
Encrypted ECR repositories
β
Secrets management via Kubernetes secrets
β
HTTPS for all services
β
TLS/SSL certificates (Let's Encrypt)
- Netflix-Clone Production: Application metrics
- Kubernetes Cluster: Cluster health & resources
- Docker Containers: Container performance
- High error rate (>5% for 5 minutes)
- High latency (P95 > 1s)
- Pod restart storms
- High memory/CPU usage
- Pod not ready
- Deployment replica mismatch
- Slack channels (#alerts, #critical-alerts)
- PagerDuty for critical incidents
- Email notifications
netflix-clone-gitops/
βββ k8s/
β βββ base/
β β βββ deployment.yaml
β β βββ service.yaml
β β βββ kustomization.yaml
β βββ overlays/
β βββ production/
β β βββ kustomization.yaml
β βββ staging/
β βββ kustomization.yaml
βββ argocd/
βββ application.yaml
βββ applicationset.yaml
- Code Push: Developer pushes to Git
- Jenkins: Runs pipeline, pushes image to ECR
- GitOps Repo Update: Jenkins updates image tag in Git
- ArgoCD Sync: Detects Git changes, syncs to cluster
- Deployment: Rolling update with zero downtime
- HPA: Automatically scales 3-10 pods based on CPU/Memory
- Rolling Updates: Zero downtime deployments
- Pod Disruption Budget: Maintains minimum availability
- Node Affinity: Spreads pods across nodes
- Redis caching layer
- Docker layer caching
- Prometheus query optimization
- Grafana dashboard caching
- CPU: 100m request / 500m limit
- Memory: 256m request / 512m limit
- Ephemeral storage quotas
- Automatic pod eviction policies
# Check pod status
kubectl describe pod <pod-name> -n production
# View logs
kubectl logs <pod-name> -n production
# Get events
kubectl get events -n production --sort-by='.lastTimestamp'# Check Prometheus targets
kubectl port-forward svc/prometheus 9090:9090 -n monitoring
# Visit http://localhost:9090/targets
# Check Grafana datasources
kubectl port-forward svc/grafana 3000:3000 -n monitoring
# Visit http://localhost:3000# Check Jenkins logs
kubectl logs -l app.kubernetes.io/name=jenkins -n jenkins
# Access Jenkins console
kubectl port-forward svc/jenkins 8080:8080 -n jenkins| File | Purpose |
|---|---|
Dockerfile |
Container image definition |
Jenkinsfile |
CI/CD pipeline configuration |
k8s-deployment.yaml |
Kubernetes deployment manifests |
argocd-applicationset.yaml |
GitOps deployment config |
prometheus-setup.yaml |
Prometheus monitoring setup |
grafana-setup.yaml |
Grafana visualization setup |
docker-compose.yml |
Local development stack |
setup-devsecops-pipeline.sh |
Automated AWS setup script |
β
OWASP Top 10: Addressed in design
β
CIS Kubernetes Benchmarks: Implemented
β
NIST Cybersecurity: Aligned
β
PCI-DSS: Encryption & audit logging
β
HIPAA: Encryption at rest & in transit
- Request rate (req/s)
- Error rate (%)
- P50/P95/P99 latency
- Active connections
- CPU usage (%)
- Memory usage (%)
- Disk usage (%)
- Network I/O
- Pod restart count
- Deployment replicas status
- HPA scaling events
- Node resource utilization
- Create feature branch
- Make changes & test locally
- Run security scans
- Create PR
- Jenkins pipeline runs automatically
- After approval, merge triggers production deployment
- Architecture Docs:
/docs/architecture.md - API Documentation:
/docs/api.md - Troubleshooting Guide:
/docs/troubleshooting.md - Security Guidelines:
/docs/security.md
Proprietary - Netflix-Clone Project
This DevSecOps pipeline provides:
- β Automated Security: Multiple scanning tools integrated
- β Continuous Deployment: GitOps-based auto-deployment
- β Comprehensive Monitoring: Real-time metrics & alerts
- β High Availability: Auto-scaling & failover
- β Production-Ready: Battle-tested components
- β Compliance-Ready: Security best practices
Last Updated: 2025-03-24
Version: 1.0.0