Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README-K8S.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@
- AWS EKS (Kubernetes)
- Helm (Monitoring using grafana and prometheus)

## Architecture
How a change reaches production: the Jenkins CI job scans, tests and pushes the image, the CD job commits the new tag to `kubernetes/`, and ArgoCD syncs it to EKS.

![CI/CD flow](images/flow.png)

What runs where on AWS: the Master EC2 machine hosts Jenkins and SonarQube; the EKS cluster runs ArgoCD, the bankapp and MySQL workloads behind ingress-nginx with cert-manager TLS, and Prometheus/Grafana for monitoring.

![EKS deployment](images/eks-deployment.png)

Diagram sources are in [docs/diagrams](docs/diagrams/README.md).

### Steps to deploy:

### Pre-requisites:
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@
- AWS EKS (Kubernetes)
- Helm (Monitoring using grafana and prometheus)

## Architecture
How a change reaches production: the Jenkins CI job scans, tests and pushes the image, the CD job commits the new tag to `kubernetes/`, and ArgoCD syncs it to EKS.

![CI/CD flow](images/flow.png)

What runs where on AWS: the Master EC2 machine hosts Jenkins and SonarQube; the EKS cluster runs ArgoCD, the bankapp and MySQL workloads behind ingress-nginx with cert-manager TLS, and Prometheus/Grafana for monitoring.

![EKS deployment](images/eks-deployment.png)

Diagram sources are in [docs/diagrams](docs/diagrams/README.md).

### Steps to deploy:

### Pre-requisites:
Expand Down
10 changes: 6 additions & 4 deletions cicd.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#### CICD Workflow
- Cloning the Project code from GitHub.
- Build docker image and push it to docker hub.
- Pull image from docker hub and deploy application using docker compose .
- **BankApp-CI** ([Jenkinsfile](Jenkinsfile)): workspace cleanup, Git checkout, Trivy filesystem scan, OWASP dependency check, SonarQube analysis and quality gate, Docker build, Cypress E2E smoke suite, then push of `bankapp:DOCKER_TAG` to DockerHub.
- **BankApp-CD** ([GitOps/Jenkinsfile](GitOps/Jenkinsfile)): triggered by a successful CI run with the same `DOCKER_TAG`; updates the image tag in `kubernetes/bankapp-deployment`, commits and pushes it to the `DevOps` branch, and sends an email notification.
- **ArgoCD** watches `kubernetes/` on the `DevOps` branch and syncs the manifests to the EKS cluster, which pulls the new image from DockerHub.

![Login diagram](images/flow.png)
![CI/CD flow](images/flow.png)

The runtime layout on EKS is shown in [images/eks-deployment.png](images/eks-deployment.png); diagram sources are in [docs/diagrams](docs/diagrams/README.md).
#### Creating CICD pipeline

1. #### Install Jenkins and access on port 8080
Expand Down
15 changes: 15 additions & 0 deletions docs/diagrams/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Architecture diagrams

| Source | Rendered image | Used in |
| --- | --- | --- |
| [cicd-flow.dot](cicd-flow.dot) | [images/flow.png](../../images/flow.png) | `cicd.md`, `README.md`, `README-K8S.md` |
| [eks-deployment.dot](eks-deployment.dot) | [images/eks-deployment.png](../../images/eks-deployment.png) | `cicd.md`, `README.md`, `README-K8S.md` |

The sources are [Graphviz](https://graphviz.org/) DOT files. After editing one, re-render both PNGs from the repo root:

```bash
sudo apt-get install -y graphviz # once
./docs/diagrams/render.sh
```

Keep the diagrams in step with `Jenkinsfile`, `GitOps/Jenkinsfile`, `kubernetes/` and the setup steps in `README.md`.
68 changes: 68 additions & 0 deletions docs/diagrams/cicd-flow.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// CI/CD flow for the DevOps branch: Jenkins CI (Jenkinsfile) -> Jenkins CD (GitOps/Jenkinsfile) -> ArgoCD -> EKS.
// Render with docs/diagrams/render.sh (writes images/flow.png).
digraph cicd_flow {
graph [rankdir=TB, newrank=true, fontname="DejaVu Sans", bgcolor="#f7fbff", pad=0.4, nodesep=0.3, ranksep=0.55,
label="Springboot-BankApp CI/CD (DevOps branch)", labelloc=t, fontsize=26];
node [fontname="DejaVu Sans", fontsize=16, shape=box, style="rounded,filled", fillcolor=white, color="#5b6b7b", penwidth=1.2, height=0.6];
edge [fontname="DejaVu Sans", fontsize=14, color="#44546a", penwidth=1.3];

dev [label="Developer", shape=oval, fillcolor="#e8eef6"];
github [label="GitHub repo\nbranch: DevOps", fillcolor="#24292f", fontcolor=white, color="#24292f"];
gha [label="GitHub Actions: e2e.yml\nCypress smoke on PRs and\npushes to DevOps", fillcolor="#f3f0ff", style="rounded,filled,dashed"];

subgraph cluster_ci {
label="Jenkins job: BankApp-CI (Jenkinsfile, shared library vars/)"; style="rounded,filled"; fillcolor="#fff4e5"; color="#d9822b"; fontsize=19;
ci1 [label="Workspace\ncleanup"];
ci2 [label="Git: code\ncheckout"];
ci3 [label="Trivy:\nfilesystem scan", fillcolor="#fde8e8"];
ci4 [label="OWASP:\ndependency check", fillcolor="#fde8e8"];
ci5 [label="SonarQube:\ncode analysis", fillcolor="#e6f0ff"];
ci6 [label="SonarQube:\nquality gate", fillcolor="#e6f0ff"];
ci7 [label="Docker: build\nbankapp:DOCKER_TAG"];
ci8 [label="E2E: Cypress smoke\n(docker compose stack)", fillcolor="#eaf7ea"];
ci9 [label="Docker: push\nto DockerHub"];
ci1 -> ci2 -> ci3 -> ci4 -> ci5;
ci5 -> ci6;
// second row runs right-to-left (tail-left placement + dir=back keeps the snake layout)
ci7 -> ci6 [dir=back]; ci8 -> ci7 [dir=back]; ci9 -> ci8 [dir=back];
}

sonar [label="SonarQube server", shape=cylinder, fillcolor="#e6f0ff"];
dockerhub [label="DockerHub\nbankapp image", shape=cylinder, fillcolor="#e3f2fd", color="#1d63ed"];

subgraph cluster_cd {
label="Jenkins job: BankApp-CD (GitOps/Jenkinsfile)"; style="rounded,filled"; fillcolor="#eef7ff"; color="#2b6cb0"; fontsize=19;
cd1 [label="Workspace cleanup\n+ Git checkout"];
cd2 [label="Verify\nDOCKER_TAG"];
cd3 [label="Update image tag in\nkubernetes/bankapp-deployment"];
cd4 [label="Git commit + push\nto DevOps"];
cd5 [label="Email notification\n(emailext)"];
cd1 -> cd2 -> cd3 -> cd4 -> cd5;
}

manifests [label="GitHub repo (same), DevOps\nkubernetes/ manifests", fillcolor="#24292f", fontcolor=white, color="#24292f"];

subgraph cluster_k8s {
label="AWS EKS cluster: bankapp"; style="rounded,filled"; fillcolor="#fff8e1"; color="#ff9900"; fontsize=19;
argocd [label="ArgoCD\n(argocd namespace)", fillcolor="#fde7d9", color="#ef7b4d"];
bankapp [label="bankapp-namespace\nbankapp-deploy + MySQL", fillcolor="#e8f5e9", color="#2e7d32"];
bankapp -> argocd [dir=back, label=" sync"];
}

dev -> github [label=" git push"];
github -> ci1 [label=" webhook / poll SCM"];
github -> gha [style=dashed];
ci5 -> sonar [dir=both, style=dashed, label=" analysis +\n quality gate"];
ci9 -> dockerhub [label=" push :DOCKER_TAG"];
ci9 -> cd1 [label=" on success: build job BankApp-CD\n (DOCKER_TAG)", color="#2b6cb0", fontcolor="#2b6cb0", penwidth=1.8];
cd4 -> manifests [label=" commit new tag", color="#2b6cb0", fontcolor="#2b6cb0"];
argocd -> manifests [dir=back, label=" watches", style=dashed, color="#ef7b4d", fontcolor="#ef7b4d"];
dockerhub -> bankapp [label=" image pull", style=dashed];

{ rank=same; dev; github; gha; }
{ rank=same; ci1; ci2; ci3; ci4; ci5; }
{ rank=same; ci6; ci7; ci8; ci9; }
{ rank=same; sonar; dockerhub; }
{ rank=same; cd1; cd2; cd3; cd4; cd5; }
{ rank=same; manifests; argocd; bankapp; }
}
90 changes: 90 additions & 0 deletions docs/diagrams/eks-deployment.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// Runtime deployment on AWS EKS: kubernetes/ manifests synced by ArgoCD, monitoring via kube-prometheus-stack (Helm).
// Render with docs/diagrams/render.sh (writes images/eks-deployment.png).
digraph eks_deployment {
graph [rankdir=TB, newrank=true, compound=true, fontname="DejaVu Sans", bgcolor="#f7fbff", pad=0.4, nodesep=0.35, ranksep=0.45,
label="Springboot-BankApp deployment on AWS EKS (DevOps branch)", labelloc=t, fontsize=26];
node [fontname="DejaVu Sans", fontsize=16, shape=box, style="rounded,filled", fillcolor=white, color="#5b6b7b", penwidth=1.2];
edge [fontname="DejaVu Sans", fontsize=14, color="#44546a", penwidth=1.3];

user [label="Bank customer\n(browser)", shape=oval, fillcolor="#e8eef6"];
admin [label="DevOps engineer", shape=oval, fillcolor="#e8eef6"];

github [label="GitHub repo\nDevOps branch\nkubernetes/ manifests", fillcolor="#24292f", fontcolor=white, color="#24292f"];
dockerhub [label="DockerHub\nbankapp image", shape=cylinder, fillcolor="#e3f2fd", color="#1d63ed"];
letsencrypt [label="Let's Encrypt\n(ACME)", fillcolor="#f1f8e9"];

subgraph cluster_aws {
label="AWS us-west-1"; style="rounded,filled"; fillcolor="#fffaf2"; color="#ff9900"; fontsize=20;

subgraph cluster_master {
label="Master EC2 (t2.medium)"; style="rounded,filled"; fillcolor="#fff4e5"; color="#d9822b"; fontsize=18;
jenkins [label="Jenkins :8081\nBankApp-CI / BankApp-CD", fillcolor=white];
sonar [label="SonarQube :9000\n(Docker container)", fillcolor="#e6f0ff"];
tools [label="Docker, Trivy, OWASP DC\nkubectl, eksctl, argocd CLI, helm", fillcolor=white];
}

subgraph cluster_eks {
label="EKS cluster: bankapp (eksctl, nodegroup 2 x t2.medium)"; style="rounded,filled"; fillcolor="#fff8e1"; color="#ff9900"; fontsize=19;

subgraph cluster_ingress_ns {
label="ingress-nginx / cert-manager"; style="rounded,filled"; fillcolor="#f4f4f4"; color="#9e9e9e"; fontsize=17;
lb [label="ingress-nginx controller\n(Service type LoadBalancer)", fillcolor="#e8f5e9"];
certmgr [label="cert-manager\nClusterIssuer letsencrypt-prod", fillcolor="#f1f8e9"];
}

subgraph cluster_argocd {
label="namespace: argocd"; style="rounded,filled"; fillcolor="#fdf0e8"; color="#ef7b4d"; fontsize=17;
argocd [label="ArgoCD server (NodePort)\nApplication: bankapp", fillcolor="#fde7d9", color="#ef7b4d"];
}

subgraph cluster_app {
label="namespace: bankapp-namespace"; style="rounded,filled"; fillcolor="#eef8ee"; color="#2e7d32"; fontsize=17;
ingress [label="Ingress bankapp-ingress\nTLS: bankapp-tls-secret"];
svc [label="Service bankapp-service\nClusterIP :8080"];
deploy [label="Deployment bankapp-deploy\nSpring Boot pods :8080\n(2 replicas)", fillcolor="#c8e6c9", color="#2e7d32"];
hpa [label="HPA bankapp-hpa\n1-5 pods @ 40% CPU", fillcolor=white];
config [label="ConfigMap bankapp-config\nSecret mysql-secret", shape=note, fillcolor="#fffde7"];
mysqlsvc [label="Service mysql-svc\n:3306"];
mysql [label="Deployment mysql\nmysql:8.0 (1 replica)", fillcolor="#e3f2fd", color="#1565c0"];
pvc [label="PVC mysql-pvc -> PV\n10Gi", shape=cylinder, fillcolor="#e3f2fd", color="#1565c0"];
}

subgraph cluster_mon {
label="namespace: prometheus (Helm: kube-prometheus-stack)"; style="rounded,filled"; fillcolor="#f3eefb"; color="#7e57c2"; fontsize=17;
prom [label="Prometheus\n(NodePort)", fillcolor="#fbe9e7", color="#e65100"];
grafana [label="Grafana\n(NodePort)", fillcolor="#fff3e0", color="#f57c00"];
}
}
}

user -> lb [label=" HTTPS\n megaproject.trainwithshubham.com"];
lb -> ingress [label=" route /"];
ingress -> svc;
svc -> deploy;
hpa -> deploy [style=dashed, label=" scales"];
config -> deploy [style=dashed, label=" env"];
deploy -> mysqlsvc [label=" JDBC"];
mysqlsvc -> mysql;
mysql -> pvc;
certmgr -> ingress [style=dashed, label=" issues cert"];
letsencrypt -> certmgr [style=dashed, dir=both, label=" ACME HTTP-01"];

github -> argocd [style=dashed, color="#ef7b4d", fontcolor="#ef7b4d", label=" watches kubernetes/"];
argocd -> ingress [color="#ef7b4d", fontcolor="#ef7b4d", label=" sync / apply", lhead=cluster_app];
dockerhub -> deploy [style=dashed, label=" image pull"];

jenkins -> sonar [style=dashed, label=" scan"];
dockerhub -> jenkins [dir=back, label=" push image"];
github -> jenkins [dir=back, label=" commit new\n image tag"];

prom -> deploy [constraint=false, style=dashed, color="#7e57c2", fontcolor="#7e57c2", label=" scrape cluster,\n nodes, workloads"];
grafana -> prom [label=" query", color="#7e57c2", fontcolor="#7e57c2"];

admin -> tools [label=" SSH"];
admin -> argocd [style=dotted, label=" UI"];
admin -> grafana [style=dotted, label=" dashboards"];

{ rank=same; dockerhub; github; admin; user; letsencrypt; }
// ordering hints that keep the layout compact
sonar -> argocd [style=invis]; tools -> lb [style=invis];
}
6 changes: 6 additions & 0 deletions docs/diagrams/render.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
# Re-renders the architecture diagrams from their Graphviz sources. Requires graphviz (`dot`).
set -euo pipefail
cd "$(dirname "$0")/../.."
dot -Gdpi=110 -Tpng docs/diagrams/cicd-flow.dot -o images/flow.png
dot -Gdpi=110 -Tpng docs/diagrams/eks-deployment.dot -o images/eks-deployment.png
Binary file added images/eks-deployment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/flow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading