An open API service indexing awesome lists of open source software.

https://github.com/lokeshkarra/filehub-server-infra-devsecops

Complete CI/CD Pipeline using Jenkins and ArgoCD
https://github.com/lokeshkarra/filehub-server-infra-devsecops

Last synced: 4 months ago
JSON representation

Complete CI/CD Pipeline using Jenkins and ArgoCD

Awesome Lists containing this project

README

          

# ๐Ÿ“ FileHub Server - Cloud-Native Django Backend

A scalable, secure, and production-ready **Django backend** for a file management platform โ€” built with modern DevSecOps principles using **Kubernetes, Jenkins, Argo CD, Terraform, AWS, Prometheus, and Grafana**.

---

## Architecture

---

## ๐Ÿš€ Tech Stack

| Layer | Tech Used |
|---------------|------------------------------------------------|
| **Backend** | Django REST Framework, PostgreSQL (AWS RDS) |
| **CI/CD** | Jenkins (CI), Argo CD (CD), Docker |
| **Infra** | AWS EKS, RDS, S3, VPC, IAM โ€” provisioned via Terraform |
| **Monitoring**| Prometheus, Grafana, Node Exporter, Django Metrics |
| **Storage** | AWS S3 for static files and uploads |
| **Frontend** | React + TypeScript (Hosted on Netlify) |

---

## ๐Ÿ“ฆ Features

- ๐Ÿงพ RESTful API for file management (upload, list, delete)
- โ˜๏ธ Static files uploaded directly to **AWS S3**
- ๐Ÿณ Dockerized and deployed via **Kubernetes (EKS)**
- ๐Ÿ” Continuous Integration via **Jenkins**
- ๐Ÿš€ Continuous Deployment via **Argo CD** (GitOps)
- ๐Ÿ“ˆ Application metrics via **django-prometheus**
- ๐Ÿ“Š Monitoring dashboards via **Grafana**
- ๐Ÿ” Follows DevSecOps best practices

---

## ๐Ÿงฉ Architecture

```txt
+------------------+
| Netlify Frontend|
+--------+---------+
|
v
+--------+---------+
| Django Backend | <-- EKS Deployment (Docker)
| REST API |
+--------+---------+
|
+-----------------+------------------+
| |
v v
PostgreSQL (RDS) AWS S3 (Static files)
```

---

## โš™๏ธ Frontend Repo

[https://github.com/lokeshkarra/filehub-client.git](https://github.com/lokeshkarra/filehub-client.git)

---

## โš™๏ธ Infrastructure as Code (IaC)

Infrastructure is provisioned using **Terraform**:

- `terraform/vpc` - VPC, subnets, routing
- `terraform/iam` - IAM roles for EKS
- `terraform/eks` - EKS cluster + node groups

### ๐Ÿš€ Deploy:
```bash
terraform init
terraform apply
aws eks update-kubeconfig --name --region
```

---

## ๐Ÿ› ๏ธ Jenkins CI Pipeline

The Jenkins pipeline automates:

- Code checkout and build
- Docker image build + push
- Kubernetes manifest update (optional)
- Git commit triggers Argo CD sync

---

## ๐ŸŒ€ Argo CD for GitOps Deployment

- Automatically deploys any change in Kubernetes YAMLs
- Keeps Git and cluster always in sync

```bash
argocd app create filehub-backend \
--repo https://github.com/yourusername/your-k8s-manifests.git \
--path k8s \
--dest-server https://kubernetes.default.svc \
--dest-namespace default
```

---

## ๐Ÿ” Secure Secrets with SealedSecrets

All sensitive environment variables and Django secrets are stored using **SealedSecrets**, ensuring Kubernetes secrets are encrypted and Git-safe.

- Replace `k8s/secrets.yaml` with `k8s/sealed-secret.yaml`
- Sealed using `kubeseal` and Bitnami SealedSecrets controller
- Automatically decrypted and mounted at runtime in cluster

### ๐Ÿ”‘ How to seal a secret:

```bash
kubectl create secret generic django-secret \
--from-literal=SECRET_KEY='your-secret-key' \
--dry-run=client -o yaml > secret.yaml

kubeseal --controller-name=sealed-secrets \
--controller-namespace=kube-system \
-o yaml < secret.yaml > sealed-secret.yaml
```

---

## ๐Ÿ“Š Monitoring

- Prometheus scrapes Django metrics via `/metrics` endpoint
- Grafana dashboards visualize request count, latency, and error rates
- Node Exporter monitors system-level metrics

> Dashboards auto-provisioned via Terraform or Helm

---

## ๐Ÿ” Django Metrics Integration

```python
# settings.py
INSTALLED_APPS += ["django_prometheus"]
MIDDLEWARE = [
"django_prometheus.middleware.PrometheusBeforeMiddleware",
...
"django_prometheus.middleware.PrometheusAfterMiddleware",
]

# urls.py
path('', include('django_prometheus.urls'))
```

---

## ๐Ÿงช API Testing

Refer the following Link
[Github repo](https://github.com/lokeshkarra/filehub-server/blob/main/README.md#authentication)

---

## ๐Ÿšง Work in Progress

- [x] Backend API
- [x] Docker & Kubernetes deployment
- [x] Argo CD GitOps
- [x] Jenkins CI Pipeline
- [x] SealedSecrets for secure secrets
- [ ] Prometheus + Grafana monitoring
- [ ] Unit and integration tests
- [ ] Advanced S3 permission hardening

---

## ๐Ÿง  Learning Outcomes

- Kubernetes app deployment with EKS
- Secure AWS infrastructure provisioning via Terraform
- GitOps CI/CD using Argo CD
- End-to-end monitoring with Prometheus and Grafana
- Production-grade Django application design

---

## ๐Ÿ“ Repo Structure

```
.
โ”œโ”€โ”€ app_code/
โ”‚ โ””โ”€โ”€ backend/
โ”‚ โ”œโ”€โ”€ Dockerfile
โ”‚ โ””โ”€โ”€ Django Server Code...
โ”œโ”€โ”€ jenkins-pipeline/
โ”‚ โ””โ”€โ”€ jenkinsfile-backend
โ”œโ”€โ”€ terraform/
โ”‚ โ”œโ”€โ”€ main.tf
โ”‚ โ”œโ”€โ”€ variable.tf
โ”‚ โ”œโ”€โ”€ outputs.tf
โ”‚ โ”œโ”€โ”€ vpc/
โ”‚ โ”œโ”€โ”€ eks/
โ”‚ โ”œโ”€โ”€ ec2/
โ”‚ โ””โ”€โ”€ iam/
โ””โ”€โ”€ k8s/
โ”œโ”€โ”€ deployment.yaml
โ”œโ”€โ”€ service.yaml
โ”œโ”€โ”€ sealed-secret.yaml <-- ๐Ÿ” Sealed Secret
```

---

## ๐Ÿ“œ License

[Apache 2.0](https://github.com/lokeshkarra/filehub-server-infra-devsecops?tab=Apache-2.0-1-ov-file)