Refer to the official project walkthrough/documentation for a full setup.
- Provision an EC2 instance with Ubuntu 22.04.
- Connect via SSH.
git clone https://github.com/AslinDhurai/DevSecOps-Project.gitInstall Docker:
sudo apt-get update
sudo apt-get install docker.io -y
sudo usermod -aG docker $USER
newgrp docker
sudo chmod 777 /var/run/docker.sockBuild and run container:
docker build -t netflix .
docker run -d --name netflix -p 8081:80 netflix:latest
# cleanup
docker stop <containerid>
docker rmi -f netflixIf the app shows an API error, generate and pass your TMDB key.
- Login/Register at TMDB.
- Go to Profile → Settings → API.
- Create API key and submit details.
- Rebuild image with key:
docker build --build-arg TMDB_V3_API_KEY=<your-api-key> -t netflix .Run SonarQube:
docker run -d --name sonar -p 9000:9000 sonarqube:lts-communityAccess SonarQube:
http://<public-ip>:9000- Default credentials:
admin / admin
Install Trivy:
sudo apt-get install wget apt-transport-https gnupg lsb-release
wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo apt-key add -
echo deb https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main | sudo tee -a /etc/apt/sources.list.d/trivy.list
sudo apt-get update
sudo apt-get install trivyScan image:
trivy image <imageid>- Connect SonarQube in Jenkins.
- Configure project analysis and quality gate.
sudo apt update
sudo apt install fontconfig openjdk-17-jre
java -version
sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \
https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
/etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt-get update
sudo apt-get install jenkins
sudo systemctl start jenkins
sudo systemctl enable jenkinsAccess Jenkins:
http://<public-ip>:8080
Go to Manage Jenkins → Plugins → Available Plugins and install:
- Eclipse Temurin Installer
- SonarQube Scanner
- NodeJS Plugin
- Email Extension Plugin
- OWASP Dependency-Check
- Docker-related plugins:
- Docker
- Docker Commons
- Docker Pipeline
- Docker API
- docker-build-step
Go to Manage Jenkins → Tools:
- Install JDK 17
- Install NodeJS 16
- Install Sonar Scanner tool
- Configure OWASP Dependency-Check as
DP-Check
Go to Manage Jenkins → Credentials:
- Add Sonar token as Secret Text (e.g.
Sonar-token) - Add DockerHub credentials (ID used in pipeline:
docker)
pipeline {
agent any
tools {
jdk 'jdk17'
nodejs 'node16'
}
environment {
SCANNER_HOME = tool 'sonar-scanner'
}
stages {
stage('clean workspace') {
steps {
cleanWs()
}
}
stage('Checkout from Git') {
steps {
git branch: 'main', url: 'https://github.com/AslinDhurai/DevSecOps-Project.git'
}
}
stage("Sonarqube Analysis") {
steps {
withSonarQubeEnv('sonar-server') {
sh '''$SCANNER_HOME/bin/sonar-scanner -Dsonar.projectName=Netflix \
-Dsonar.projectKey=Netflix'''
}
}
}
stage("quality gate") {
steps {
script {
waitForQualityGate abortPipeline: false, credentialsId: 'Sonar-token'
}
}
}
stage('Install Dependencies') {
steps {
sh "npm install"
}
}
}
}pipeline{
agent any
tools{
jdk 'jdk17'
nodejs 'node16'
}
environment {
SCANNER_HOME=tool 'sonar-scanner'
}
stages {
stage('clean workspace'){
steps{
cleanWs()
}
}
stage('Checkout from Git'){
steps{
git branch: 'main', url: 'https://github.com/AslinDhurai/DevSecOps-Project.git'
}
}
stage("Sonarqube Analysis "){
steps{
withSonarQubeEnv('sonar-server') {
sh ''' $SCANNER_HOME/bin/sonar-scanner -Dsonar.projectName=Netflix \
-Dsonar.projectKey=Netflix '''
}
}
}
stage("quality gate"){
steps {
script {
waitForQualityGate abortPipeline: false, credentialsId: 'Sonar-token'
}
}
}
stage('Install Dependencies') {
steps {
sh "npm install"
}
}
stage('OWASP FS SCAN') {
steps {
dependencyCheck additionalArguments: '--scan ./ --disableYarnAudit --disableNodeAudit', odcInstallation: 'DP-Check'
dependencyCheckPublisher pattern: '**/dependency-check-report.xml'
}
}
stage('TRIVY FS SCAN') {
steps {
sh "trivy fs . > trivyfs.txt"
}
}
stage("Docker Build & Push"){
steps{
script{
withDockerRegistry(credentialsId: 'docker', toolName: 'docker'){
sh "docker build --build-arg TMDB_V3_API_KEY=<yourapikey> -t netflix ."
sh "docker tag netflix aslindhurai/netflix:latest "
sh "docker push aslindhurai/netflix:latest "
}
}
}
}
stage("TRIVY"){
steps{
sh "trivy image aslindhurai/netflix:latest > trivyimage.txt"
}
}
stage('Deploy to container'){
steps{
sh 'docker run -d --name netflix -p 8081:80 aslindhurai/netflix:latest'
}
}
}
}If Docker login fails in Jenkins agent:
sudo su
sudo usermod -aG docker jenkins
sudo systemctl restart jenkinsNote: Set up monitoring on a separate/new EC2 instance (Ubuntu 22.04) instead of the Jenkins machine.
Create user and download:
sudo useradd --system --no-create-home --shell /bin/false prometheus
wget https://github.com/prometheus/prometheus/releases/download/v2.47.1/prometheus-2.47.1.linux-amd64.tar.gzExtract and place files:
tar -xvf prometheus-2.47.1.linux-amd64.tar.gz
cd prometheus-2.47.1.linux-amd64/
sudo mkdir -p /data /etc/prometheus
sudo mv prometheus promtool /usr/local/bin/
sudo mv consoles/ console_libraries/ /etc/prometheus/
sudo mv prometheus.yml /etc/prometheus/prometheus.yml
sudo chown -R prometheus:prometheus /etc/prometheus/ /data/Create service file:
sudo nano /etc/systemd/system/prometheus.serviceUse:
[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target
StartLimitIntervalSec=500
StartLimitBurst=5
[Service]
User=prometheus
Group=prometheus
Type=simple
Restart=on-failure
RestartSec=5s
ExecStart=/usr/local/bin/prometheus \
--config.file=/etc/prometheus/prometheus.yml \
--storage.tsdb.path=/data \
--web.console.templates=/etc/prometheus/consoles \
--web.console.libraries=/etc/prometheus/console_libraries \
--web.listen-address=0.0.0.0:9090 \
--web.enable-lifecycle
[Install]
WantedBy=multi-user.targetEnable and start:
sudo systemctl enable prometheus
sudo systemctl start prometheus
sudo systemctl status prometheusAccess:
http://<your-server-ip>:9090
sudo useradd --system --no-create-home --shell /bin/false node_exporter
wget https://github.com/prometheus/node_exporter/releases/download/v1.6.1/node_exporter-1.6.1.linux-amd64.tar.gz
tar -xvf node_exporter-1.6.1.linux-amd64.tar.gz
sudo mv node_exporter-1.6.1.linux-amd64/node_exporter /usr/local/bin/
rm -rf node_exporter*Create service file:
sudo nano /etc/systemd/system/node_exporter.serviceUse:
[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target
StartLimitIntervalSec=500
StartLimitBurst=5
[Service]
User=node_exporter
Group=node_exporter
Type=simple
Restart=on-failure
RestartSec=5s
ExecStart=/usr/local/bin/node_exporter --collector.logind
[Install]
WantedBy=multi-user.targetEnable and start:
sudo systemctl enable node_exporter
sudo systemctl start node_exporter
sudo systemctl status node_exporterUpdate /etc/prometheus/prometheus.yml:
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'node_exporter'
static_configs:
- targets: ['localhost:9100']
- job_name: 'jenkins'
metrics_path: '/prometheus'
static_configs:
- targets: ['<your-jenkins-ip>:<your-jenkins-port>']Validate and reload:
promtool check config /etc/prometheus/prometheus.yml
curl -X POST http://localhost:9090/-/reloadTargets page:
http://<your-prometheus-ip>:9090/targets
Install dependencies and Grafana:
sudo apt-get update
sudo apt-get install -y apt-transport-https software-properties-common
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
sudo apt-get update
sudo apt-get -y install grafanaEnable and start:
sudo systemctl enable grafana-server
sudo systemctl start grafana-server
sudo systemctl status grafana-serverAccess Grafana:
http://<your-server-ip>:3000- Default login:
admin / admin(change password on first login)
Add Prometheus datasource:
- URL:
http://localhost:9090 - Click Save & Test
Import dashboard:
- Use dashboard ID
1860(Node Exporter full)
- Configure Jenkins email notifications (or equivalent notification channel).
This phase sets up a Kubernetes cluster using Amazon EKS, configures access using kubectl, installs monitoring tools using Helm, and deploys applications using ArgoCD GitOps.
- Go to AWS Console → Amazon EKS
- Click Create Cluster
- Provide the following configuration:
Cluster Name: netflix-cluster
Kubernetes Version: Latest Stable
Cluster Service Role: Create new role or select existing EKS role
VPC: Default or existing VPC
Subnets: Select at least 2 subnets
Endpoint Access: Public
- Click Create
Cluster creation may take 10–15 minutes.
After cluster creation:
- Open the created cluster
- Navigate to Compute → Add Node Group
- Configure:
Node Group Name: netflix-workers
Instance Type: t3.medium
Desired Size: 2
Minimum Size: 1
Maximum Size: 3
- Click Create Node Group
Wait until the nodes are in Ready state.
Open AWS CloudShell from the AWS Console.
CloudShell already includes the required tools:
aws CLI
kubectl
eksctl
Run the following command inside CloudShell to configure access to the cluster.
aws eks update-kubeconfig --region ap-south-1 --name netflix-cluster
### Verify Cluster Connectivity
Run the following command to verify that the EKS cluster nodes are connected.
```bash
kubectl get nodesExpected output:
NAME STATUS ROLES AGE
ip-xxx-xxx-xxx-xxx Ready <none> 2m
Helm is the Kubernetes package manager used to deploy applications and services.
Install Helm:
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bashVerify installation:
helm versionNode Exporter collects infrastructure metrics from Kubernetes nodes.
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo updatekubectl create namespace monitoringhelm install node-exporter prometheus-community/prometheus-node-exporter \
--namespace monitoringkubectl get pods -n monitoringkubectl create namespace argocdkubectl apply -n argocd \
-f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yamlkubectl get pods -n argocdWait until all pods show Running status.
By default ArgoCD is not externally accessible.
Expose it using NodePort.
kubectl patch svc argocd-server \
-n argocd \
-p '{"spec": {"type": "NodePort"}}'Check exposed ports:
kubectl get svc argocd-server -n argocdExample output:
NAME TYPE PORT(S)
argocd-server NodePort 80:30007/TCP
To allow external access to ArgoCD UI and Node Exporter metrics, update the Security Group rules for your EKS worker nodes.
- Go to AWS Console → EC2 → Security Groups
- Select the EKS Worker Node Security Group
- Add the following Inbound Rules:
Type: Custom TCP
Port: 30007
Source: 0.0.0.0/0
Description: ArgoCD UI Access
Type: Custom TCP
Port: 9100
Source: 0.0.0.0/0
Description: Node Exporter Metrics
- Click Save Rules
These rules allow:
- Port 30007 → Access the ArgoCD Web UI
- Port 9100 → Allow Prometheus to scrape Node Exporter metrics
Get the worker node public IP:
kubectl get nodes -o wideOpen the following URL in your browser:
http://<node-public-ip>:30007
Run the following command:
kubectl -n argocd get secret argocd-initial-admin-secret \
-o jsonpath="{.data.password}" | base64 -dLogin credentials:
Username: admin
Password: <output-from-command>
- Login to the ArgoCD UI
- Click New App
- Configure the application:
Application Name: netflix-app
Project: default
Repository URL: <your GitHub repository>
Path: manifests
Cluster: https://kubernetes.default.svc
Namespace: default
Enable the following options:
Auto Sync
Prune
Self Heal
Click Create to deploy the application.
- Terminate EC2 instances & EKS Cluster that are no longer required.
- If your setup differs (usernames, IPs, credentials IDs), replace placeholders accordingly.
- You can also use
pipeline.txtfrom this repository directly in Jenkins.

