{"id":23141581,"url":"https://github.com/harshitsahu2311/amazon-prime-clone-app","last_synced_at":"2026-02-06T21:31:22.534Z","repository":{"id":262248407,"uuid":"886662615","full_name":"harshitsahu2311/Amazon-Prime-Clone-App","owner":"harshitsahu2311","description":"In this project, I have deployed an amazon prime clone app in Kind cluster using ci-cd pipeline and scan the docker image and code with trivy and sonarqube. In this guide, you will get all steps from running locally to cluster.","archived":false,"fork":false,"pushed_at":"2024-11-11T18:31:29.000Z","size":25575,"stargazers_count":0,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-31T04:44:16.110Z","etag":null,"topics":["aws","git","grafana","jenkins","k8s","kind-cluster","sonarqube"],"latest_commit_sha":null,"homepage":"https://harshitsahu2311.hashnode.dev/project-end-to-end-cicd-pipeline-of-amazon-prime-clone","language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/harshitsahu2311.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-11-11T11:34:27.000Z","updated_at":"2024-12-06T14:38:40.000Z","dependencies_parsed_at":"2024-11-11T12:34:11.252Z","dependency_job_id":"a91d34a8-240a-49fa-ad76-c029b4c3c75c","html_url":"https://github.com/harshitsahu2311/Amazon-Prime-Clone-App","commit_stats":null,"previous_names":["harshitsahu2311/amazon-prime-clone-app"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/harshitsahu2311/Amazon-Prime-Clone-App","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harshitsahu2311%2FAmazon-Prime-Clone-App","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harshitsahu2311%2FAmazon-Prime-Clone-App/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harshitsahu2311%2FAmazon-Prime-Clone-App/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harshitsahu2311%2FAmazon-Prime-Clone-App/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/harshitsahu2311","download_url":"https://codeload.github.com/harshitsahu2311/Amazon-Prime-Clone-App/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harshitsahu2311%2FAmazon-Prime-Clone-App/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29177409,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-06T20:14:21.878Z","status":"ssl_error","status_checked_at":"2026-02-06T20:14:21.443Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","git","grafana","jenkins","k8s","kind-cluster","sonarqube"],"created_at":"2024-12-17T14:13:59.012Z","updated_at":"2026-02-06T21:31:22.521Z","avatar_url":"https://github.com/harshitsahu2311.png","language":"CSS","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ☸️ Deploy Amazon Prime Clone Application AWS using DevSecOps Approach 🐳\n\n![image](https://github.com/harshitsahu2311/Amazon-Prime-Clone-App/blob/main/Pictures/End%20(1).gif)\n## Project Blogs\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\n      \u003ca href=\"https://harshitsahu2311.hashnode.dev/project-end-to-end-cicd-pipeline-of-amazon-prime-clone\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://ytcards.demolab.com/?id=RDiza4DcGs8\u0026title=Blog+of+Amazon+Prime+Clone\u0026lang=en\u0026timestamp=0\u0026background_color=%230d1117\u0026title_color=%23ffffff\u0026stats_color=%23dedede\u0026max_title_lines=1\u0026width=250\u0026border_radius=5\" alt=\"Your New Video Title Here\" width=\"250\" style=\"border-radius:5px;\"\u003e\n      \u003c/a\u003e\n    \u003c/td\u003e\n     \u003ctd\u003e\n      \u003ca href=\"https://harshitsahu2311.hashnode.dev/project-automate-the-deployment-of-amazon-prime-video-clone\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://ytcards.demolab.com/?id=ZzNP0P35Kio\u0026title=Deploy+Amazon+Prime+Clone+On+local\u0026lang=en\u0026timestamp=0\u0026background_color=%230d1117\u0026title_color=%23ffffff\u0026stats_color=%23dedede\u0026max_title_lines=1\u0026width=250\u0026border_radius=5\" alt=\"Deploy Amazon Prime Video Clone On EKS Cluster\" width=\"250\" style=\"border-radius:5px;\"\u003e\n      \u003c/a\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n# Install all prerequisites\n\n\n\n## **Install AWS CLI**\n```\nsudo apt install unzip -y\ncurl \"https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip\" -o \"awscliv2.zip\"\nunzip awscliv2.zip\nsudo ./aws/install\n```\n \n## **Install Jenkins on Ubuntu:**\n\n```\n#!/bin/bash\nsudo apt update -y\nwget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | sudo tee /etc/apt/keyrings/adoptium.asc\necho \"deb [signed-by=/etc/apt/keyrings/adoptium.asc] https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main\" | sudo tee /etc/apt/sources.list.d/adoptium.list\nsudo apt update -y\nsudo apt install temurin-17-jdk -y\n/usr/bin/java --version\ncurl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc \u003e /dev/null\necho 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 \u003e /dev/null\nsudo apt-get update -y\nsudo apt-get install jenkins -y\nsudo systemctl start jenkins\nsudo systemctl status jenkins\n```\n\n## **Install Docker on Ubuntu:**\n```\n# Add Docker's official GPG key:\nsudo apt-get update\nsudo apt-get install ca-certificates curl\nsudo install -m 0755 -d /etc/apt/keyrings\nsudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc\nsudo chmod a+r /etc/apt/keyrings/docker.asc\n# Add the repository to Apt sources:\necho \\\n  \"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \\\n  $(. /etc/os-release \u0026\u0026 echo \"$VERSION_CODENAME\") stable\" | \\\n  sudo tee /etc/apt/sources.list.d/docker.list \u003e /dev/null\nsudo apt-get update\nsudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y\nsudo usermod -aG docker ubuntu\nsudo chmod 777 /var/run/docker.sock\nnewgrp docker\nsudo systemctl status docker\n```\n\n## **Install Trivy on Ubuntu:**\n\nReference Doc: https://aquasecurity.github.io/trivy/v0.55/getting-started/installation/\n```\nsudo apt-get install wget apt-transport-https gnupg\nwget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | gpg --dearmor | sudo tee /usr/share/keyrings/trivy.gpg \u003e /dev/null\necho \"deb [signed-by=/usr/share/keyrings/trivy.gpg] https://aquasecurity.github.io/trivy-repo/deb generic main\" | sudo tee -a /etc/apt/sources.list.d/trivy.list\nsudo apt-get update\nsudo apt-get install trivy\n```\n## Sonarqube Setup On Docker\n```\ndocker run -d --name sonar -p 9000:9000 sonarqube:lts-community\n```\n\n# Deployment Stages:\n ![image](https://github.com/user-attachments/assets/da872659-3bd5-4ec3-9e74-c952885d86d2)\n\n# Jenkins Stage-View:\n![stage](https://github.com/harshitsahu2311/Amazon-Prime-Clone-App/blob/main/Pictures/post%20image.png)\n\n\n\n## Jenkins Complete pipeline\n```\npipeline {\n    agent any\n\n    tools {\n        jdk 'jdk17'\n        nodejs 'node16' // Ensure 'node16' is configured in Jenkins under Manage Jenkins \u003e Global Tool Configuration\n    }\n    environment {\n        SCANNER_HOME = tool 'sonar'\n    }\n\n    stages {\n        stage('Clean Workspace') {\n            steps {\n                cleanWs()\n            }\n        }\n\n\n        stage('Git Checkout') {\n            steps {\n                git branch: 'main', url: 'https://github.com/harshitsahu2311/Amazon-Prime-Clone-App.git'\n            }\n        }\n        stage(\"Sonarqube Analysis\") {\n            steps {\n                withSonarQubeEnv('sonar') {\n                    sh '''\n                        $SCANNER_HOME/bin/sonar-scanner \\\n                        -Dsonar.projectName=prime-clone \\\n                        -Dsonar.projectKey=prime-clone\n                    '''\n                }\n            }\n        }\n        stage(\"quality gate\") {\n            steps {\n                script {\n                    waitForQualityGate abortPipeline: false, credentialsId: 'sonar-cred'\n                }\n            }\n        }\n        stage (\"Trivy File Scan\") {\n            steps {\n                sh \"trivy fs . \u003e trivy.txt\"\n            }\n        }\n        stage('Build Docker Image') {\n            steps {\n                script {\n                    // Build the Docker image tagged as 'prime-clone:latest'\n                    sh \"docker build -t prime-clone:latest .\"\n                }\n            }\n        }\n        stage (\"Trivy Image Scan\") {\n            steps {\n                sh \"trivy image prime-clone:latest\"\n            }\n        }\n        stage('Tag \u0026 Push to DockerHub') {\n            steps {\n                script {\n                    withDockerRegistry(credentialsId: 'docker-cred') {\n                        sh \"docker tag prime-clone:latest harshitsahu2311/prime-clone:latest\"\n                        sh \"docker push harshitsahu2311/prime-clone:latest\"\n                    }\n                }\n            }\n        }\n        stage (\"Deploy to Kubernetes\") {\n            steps {\n                script {\n                    withCredentials([file(credentialsId: 'kuber-cred', variable: 'KUBECONFIG_FILE')]) {\n                        sh \"\"\"\n                            # Set the KUBECONFIG environment variable\n                            export KUBECONFIG=${KUBECONFIG_FILE}\n\n                            # Navigate to the Kubernetes manifests directory\n                            cd Kubernetes\n\n                            # Apply all Kubernetes manifests\n                            kubectl apply -f .\n\n                        \"\"\"\n                    }\n                }\n            }\n\n        }\n    }\n\n}\npost {\n    success {\n            echo '✅ Deployment successful!'\n            // Optional: Add notifications (e.g., email, Slack) here\n    }\n    failure {\n            echo '❌ Deployment failed.'\n            // Optional: Add notifications (e.g., email, Slack) here\n    }\n    }\n\n\n```\n**Phase 4: Monitoring**\n\n1. **Install Prometheus and Grafana:**\n\n   Set up Prometheus and Grafana to monitor your application.\n\n   **Installing Prometheus:**\n\n   First, create a dedicated Linux user for Prometheus and download Prometheus:\n\n   ```bash\n   sudo useradd --system --no-create-home --shell /bin/false prometheus\n   wget https://github.com/prometheus/prometheus/releases/download/v2.47.1/prometheus-2.47.1.linux-amd64.tar.gz\n   ```\n\n   Extract Prometheus files, move them, and create directories:\n\n   ```bash\n   tar -xvf prometheus-2.47.1.linux-amd64.tar.gz\n   cd prometheus-2.47.1.linux-amd64/\n   sudo mkdir -p /data /etc/prometheus\n   sudo mv prometheus promtool /usr/local/bin/\n   sudo mv consoles/ console_libraries/ /etc/prometheus/\n   sudo mv prometheus.yml /etc/prometheus/prometheus.yml\n   ```\n\n   Set ownership for directories:\n\n   ```bash\n   sudo chown -R prometheus:prometheus /etc/prometheus/ /data/\n   ```\n\n   Create a systemd unit configuration file for Prometheus:\n\n   ```bash\n   sudo nano /etc/systemd/system/prometheus.service\n   ```\n\n   Add the following content to the `prometheus.service` file:\n\n   ```plaintext\n   [Unit]\n   Description=Prometheus\n   Wants=network-online.target\n   After=network-online.target\n\n   StartLimitIntervalSec=500\n   StartLimitBurst=5\n\n   [Service]\n   User=prometheus\n   Group=prometheus\n   Type=simple\n   Restart=on-failure\n   RestartSec=5s\n   ExecStart=/usr/local/bin/prometheus \\\n     --config.file=/etc/prometheus/prometheus.yml \\\n     --storage.tsdb.path=/data \\\n     --web.console.templates=/etc/prometheus/consoles \\\n     --web.console.libraries=/etc/prometheus/console_libraries \\\n     --web.listen-address=0.0.0.0:9090 \\\n     --web.enable-lifecycle\n\n   [Install]\n   WantedBy=multi-user.target\n   ```\n\n   Here's a brief explanation of the key parts in this `prometheus.service` file:\n\n   - `User` and `Group` specify the Linux user and group under which Prometheus will run.\n\n   - `ExecStart` is where you specify the Prometheus binary path, the location of the configuration file (`prometheus.yml`), the storage directory, and other settings.\n\n   - `web.listen-address` configures Prometheus to listen on all network interfaces on port 9090.\n\n   - `web.enable-lifecycle` allows for management of Prometheus through API calls.\n\n   Enable and start Prometheus:\n\n   ```bash\n   sudo systemctl enable prometheus\n   sudo systemctl start prometheus\n   ```\n\n   Verify Prometheus's status:\n\n   ```bash\n   sudo systemctl status prometheus\n   ```\n\n   You can access Prometheus in a web browser using your server's IP and port 9090:\n\n   `http://\u003cyour-server-ip\u003e:9090`\n\n   **Installing Node Exporter:**\n\n   Create a system user for Node Exporter and download Node Exporter:\n\n   ```bash\n   sudo useradd --system --no-create-home --shell /bin/false node_exporter\n   wget https://github.com/prometheus/node_exporter/releases/download/v1.6.1/node_exporter-1.6.1.linux-amd64.tar.gz\n   ```\n\n   Extract Node Exporter files, move the binary, and clean up:\n\n   ```bash\n   tar -xvf node_exporter-1.6.1.linux-amd64.tar.gz\n   sudo mv node_exporter-1.6.1.linux-amd64/node_exporter /usr/local/bin/\n   rm -rf node_exporter*\n   ```\n\n   Create a systemd unit configuration file for Node Exporter:\n\n   ```bash\n   sudo nano /etc/systemd/system/node_exporter.service\n   ```\n\n   Add the following content to the `node_exporter.service` file:\n\n   ```plaintext\n   [Unit]\n   Description=Node Exporter\n   Wants=network-online.target\n   After=network-online.target\n\n   StartLimitIntervalSec=500\n   StartLimitBurst=5\n\n   [Service]\n   User=node_exporter\n   Group=node_exporter\n   Type=simple\n   Restart=on-failure\n   RestartSec=5s\n   ExecStart=/usr/local/bin/node_exporter --collector.logind\n\n   [Install]\n   WantedBy=multi-user.target\n   ```\n\n   Replace `--collector.logind` with any additional flags as needed.\n\n   Enable and start Node Exporter:\n\n   ```bash\n   sudo systemctl enable node_exporter\n   sudo systemctl start node_exporter\n   ```\n\n   Verify the Node Exporter's status:\n\n   ```bash\n   sudo systemctl status node_exporter\n   ```\n\n   You can access Node Exporter metrics in Prometheus.\n\n2. **Configure Prometheus Plugin Integration:**\n\n   Integrate Jenkins with Prometheus to monitor the CI/CD pipeline.\n\n   **Prometheus Configuration:**\n\n   To configure Prometheus to scrape metrics from Node Exporter and Jenkins, you need to modify the `prometheus.yml` file. Here is an example `prometheus.yml` configuration for your setup:\n\n   ```yaml\n   global:\n     scrape_interval: 15s\n\n   scrape_configs:\n     - job_name: 'node_exporter'\n       static_configs:\n         - targets: ['localhost:9100']\n\n     - job_name: 'jenkins'\n       metrics_path: '/prometheus'\n       static_configs:\n         - targets: ['\u003cyour-jenkins-ip\u003e:\u003cyour-jenkins-port\u003e']\n   ```\n\n   Make sure to replace `\u003cyour-jenkins-ip\u003e` and `\u003cyour-jenkins-port\u003e` with the appropriate values for your Jenkins setup.\n\n   Check the validity of the configuration file:\n\n   ```bash\n   promtool check config /etc/prometheus/prometheus.yml\n   ```\n\n   Reload the Prometheus configuration without restarting:\n\n   ```bash\n   curl -X POST http://localhost:9090/-/reload\n   ```\n\n   You can access Prometheus targets at:\n\n   `http://\u003cyour-prometheus-ip\u003e:9090/targets`\n\n\n#### Grafana\n\n**Install Grafana on Ubuntu 22.04 and Set it up to Work with Prometheus**\n\n**Step 1: Install Dependencies:**\n\nFirst, ensure that all necessary dependencies are installed:\n\n```bash\nsudo apt-get update\nsudo apt-get install -y apt-transport-https software-properties-common\n```\n\n**Step 2: Add the GPG Key:**\n\nAdd the GPG key for Grafana:\n\n```bash\nwget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -\n```\n\n**Step 3: Add Grafana Repository:**\n\nAdd the repository for Grafana stable releases:\n\n```bash\necho \"deb https://packages.grafana.com/oss/deb stable main\" | sudo tee -a /etc/apt/sources.list.d/grafana.list\n```\n\n**Step 4: Update and Install Grafana:**\n\nUpdate the package list and install Grafana:\n\n```bash\nsudo apt-get update\nsudo apt-get -y install grafana\n```\n\n**Step 5: Enable and Start Grafana Service:**\n\nTo automatically start Grafana after a reboot, enable the service:\n\n```bash\nsudo systemctl enable grafana-server\n```\n\nThen, start Grafana:\n\n```bash\nsudo systemctl start grafana-server\n```\n\n**Step 6: Check Grafana Status:**\n\nVerify the status of the Grafana service to ensure it's running correctly:\n\n```bash\nsudo systemctl status grafana-server\n```\n\n**Step 7: Access Grafana Web Interface:**\n\nOpen a web browser and navigate to Grafana using your server's IP address. The default port for Grafana is 3000. For example:\n\n`http://\u003cyour-server-ip\u003e:3000`\n\n## Monitor Kubernetes with Prometheus\n\nPrometheus is a powerful monitoring and alerting toolkit, and you'll use it to monitor your Kubernetes cluster. Additionally, you'll install the node exporter using Helm to collect metrics from your cluster nodes.\n\n### Install Node Exporter using Helm\n\nTo begin monitoring your Kubernetes cluster, you'll install the Prometheus Node Exporter. This component allows you to collect system-level metrics from your cluster nodes. Here are the steps to install the Node Exporter using Helm:\n\n1. Add the Prometheus Community Helm repository:\n\n    ```bash\n    helm repo add prometheus-community https://prometheus-community.github.io/helm-charts\n    ```\n\n2. Create a Kubernetes namespace for the Node Exporter:\n\n    ```bash\n    kubectl create namespace prometheus-node-exporter\n    ```\n\n3. Install the Node Exporter using Helm:\n\n    ```bash\n    helm install prometheus-node-exporter prometheus-community/prometheus-node-exporter --namespace prometheus-node-exporter\n    ```\n\nAdd a Job to Scrape Metrics on nodeip:9001/metrics in prometheus.yml:\n\nUpdate your Prometheus configuration (prometheus.yml) to add a new job for scraping metrics from nodeip:9001/metrics. You can do this by adding the following configuration to your prometheus.yml file:\n\n\n```\n  - job_name: 'k8s'\n    metrics_path: '/metrics'\n    static_configs:\n      - targets: ['node1Ip:9100']\n```\n\nReplace 'your-job-name' with a descriptive name for your job. The static_configs section specifies the targets to scrape metrics from, and in this case, it's set to nodeip:9001.\n\nDon't forget to reload or restart Prometheus to apply these changes to your configuration.\n\nTo deploy an application with ArgoCD, you can follow these steps, which I'll outline in Markdown format:\n\n### Deploy Application with ArgoCD\n\n1. **Install ArgoCD:**\n\n   You can install ArgoCD on your Kubernetes cluster by following the instructions provided in the [EKS Workshop](https://archive.eksworkshop.com/intermediate/290_argocd/install/) documentation.\n\n2. **Set Your GitHub Repository as a Source:**\n\n   After installing ArgoCD, you need to set up your GitHub repository as a source for your application deployment. This typically involves configuring the connection to your repository and defining the source for your ArgoCD application. The specific steps will depend on your setup and requirements.\n\n3. **Create an ArgoCD Application:**\n   - `name`: Set the name for your application.\n   - `destination`: Define the destination where your application should be deployed.\n   - `project`: Specify the project the application belongs to.\n   - `source`: Set the source of your application, including the GitHub repository URL, revision, and the path to the application within the repository.\n   - `syncPolicy`: Configure the sync policy, including automatic syncing, pruning, and self-healing.\n\n4. **Access your Application**\n   - To Access the app make sure port 30007 is open in your security group and then open a new tab paste your NodeIP:30007, your app should be running.\n\n**Phase 7: Cleanup**\n\n1. **Cleanup AWS EC2 Instances:**\n    - Terminate AWS EC2 instances that are no longer needed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharshitsahu2311%2Famazon-prime-clone-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharshitsahu2311%2Famazon-prime-clone-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharshitsahu2311%2Famazon-prime-clone-app/lists"}