├── .gitignore ├── DevSecOps ├── Jenkinsfile └── README.md ├── Dockerfile ├── Jenkinsfile ├── README.md ├── app.js ├── azure-pipelines.yml ├── docker-compose.yaml ├── k8s ├── deployment.yml ├── pod.yml ├── replica-sets.yml └── service.yml ├── kustomize ├── README.md ├── base │ ├── app-1 │ │ ├── app-1.yml │ │ └── kustomization.yml │ └── ingress │ │ ├── ingress.yml │ │ └── kustomization.yml └── overlays │ ├── dev │ ├── dev-ingress-patch.json │ └── kustomization.yml │ └── prd │ ├── kustomization.yml │ └── prd-ingress-patch.json ├── package-lock.json ├── package.json ├── sonar-project.properties ├── terraform ├── main.tf └── terraform.tf ├── test.js └── views ├── edititem.ejs └── todo.ejs /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | node_modules/ 3 | deb 4 | echo 5 | -------------------------------------------------------------------------------- /DevSecOps/Jenkinsfile: -------------------------------------------------------------------------------- 1 | 2 | pipeline { 3 | 4 | agent any 5 | environment{ 6 | SONAR_HOME = tool "Sonar" 7 | } 8 | stages { 9 | 10 | stage("Code"){ 11 | steps{ 12 | git url: "https://github.com/LondheShubham153/node-todo-cicd.git" , branch: "master" 13 | echo "Code Cloned Successfully" 14 | } 15 | } 16 | stage("SonarQube Analysis"){ 17 | steps{ 18 | withSonarQubeEnv("Sonar"){ 19 | sh "$SONAR_HOME/bin/sonar-scanner -Dsonar.projectName=nodetodo -Dsonar.projectKey=nodetodo -X" 20 | } 21 | } 22 | } 23 | stage("SonarQube Quality Gates"){ 24 | steps{ 25 | timeout(time: 1, unit: "MINUTES"){ 26 | waitForQualityGate abortPipeline: false 27 | } 28 | } 29 | } 30 | stage("OWASP"){ 31 | steps{ 32 | dependencyCheck additionalArguments: '--scan ./', odcInstallation: 'OWASP' 33 | dependencyCheckPublisher pattern: '**/dependency-check-report.xml' 34 | } 35 | } 36 | stage("Build & Test"){ 37 | steps{ 38 | sh 'docker build -t node-app-batch-6:latest .' 39 | echo "Code Built Successfully" 40 | } 41 | } 42 | stage("Trivy"){ 43 | steps{ 44 | sh "trivy image node-app-batch-6" 45 | } 46 | } 47 | stage("Push to Private Docker Hub Repo"){ 48 | steps{ 49 | withCredentials([usernamePassword(credentialsId:"DockerHubCreds",passwordVariable:"dockerPass",usernameVariable:"dockerUser")]){ 50 | sh "docker login -u ${env.dockerUser} -p ${env.dockerPass}" 51 | sh "docker tag node-app-batch-6:latest ${env.dockerUser}/node-app-batch-6:latest" 52 | sh "docker push ${env.dockerUser}/node-app-batch-6:latest" 53 | } 54 | 55 | } 56 | } 57 | stage("Deploy"){ 58 | steps{ 59 | sh "docker-compose down && docker-compose up -d" 60 | echo "App Deployed Successfully" 61 | } 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /DevSecOps/README.md: -------------------------------------------------------------------------------- 1 | # End to End DevSecOps Project for DevOps Engineers 2 | 3 | ### In this project, we will learn about DevOps and DevSecOps tools in one project: 4 | 5 | ### Tools Covered: 6 | - Linux 7 | - Git and GitHub 8 | - Docker 9 | - Docker-compose 10 | - Jenkins CI/CD 11 | - SonarQube 12 | - OWASP 13 | - Trivy 14 | 15 | # 16 | 17 | ## Pre-requisites to implement this project: 18 | 19 | - AWS EC2 instance (Ubuntu) with instance type t2.large and root volume 29GB. 20 | 21 | - Jenkins installed
22 | - Reference: Jenkins installation 23 | 24 | - Docker and docker-compose installled 25 | ```bash 26 | sudo apt-get update 27 | sudo apt-get install docker.io -y 28 | sudo apt-get install docker-compose -y 29 | ``` 30 | 31 | - Trivy installed
32 | - Reference: Trivy Installation 33 | 34 | - SonarQube Server installed 35 | ```bash 36 | docker run -itd --name sonarqube-server -p 9000:9000 sonarqube:lts-community 37 | ``` 38 | # 39 | ## Steps for Jenkins CI/CD: 40 | 41 | 1) Access Jenkins UI and setup Jenkins 42 | 43 | ![image](https://github.com/DevMadhup/node-todo-cicd/assets/121779953/1eec417e-95ab-4497-ad31-443ecd6b999e) 44 | 45 | # 46 | 47 | 2) Plugins Installation: 48 | 49 | - Go to Manage Jenkins, click on Plugins and install all the plugins listed below, we will require for other tools integration: 50 | 51 | - SonarQube Scanner (Version2.16.1) 52 | - Sonar Quality Gates (Version1.3.1) 53 | - OWASP Dependency-Check (Version5.4.3) 54 | - Docker (Version1.5) 55 | # 56 | 57 | 3) Go to SonarQube Server and create token 58 | 59 | - Click on Administration tab, then Security , then Users and create Token. 60 | - Create a webhook to notify Jenkins that Quality gates scanning is done. (We will need this step later) 61 | 62 | - Go to SonarQube Server, then Administration , then Configuration and click on Webhook , add webhook in below Format: 63 | > http://:8080/sonarqube-webhook/ 64 | 65 | Example: 66 | 67 | ```bash 68 | http://34.207.58.19:8080/sonarqube-webhook/ 69 | ``` 70 | 71 | ![image](https://github.com/DevMadhup/node-todo-cicd/assets/121779953/b9ef2301-b8ff-46f4-a457-6345d5e2dab6) 72 | 73 | 74 | ![image](https://github.com/DevMadhup/node-todo-cicd/assets/121779953/08a33164-f6a6-4c5d-8a34-7091cf8a5745) 75 | 76 | # 77 | 78 | 4) Go to Jenkins UI Manage Jenkins , then Credentials and add SonarQube Credentials. 79 | 80 | ![image](https://github.com/DevMadhup/node-todo-cicd/assets/121779953/f6db72ec-7d8c-4f4c-ae7a-55d99dd20ce9) 81 | 82 | # 83 | 84 | 5) Now, It's time to integrate SonarQube Server with Jenkins, go to Manage Jenkins , then System and look for SonarQube Servers and add SonarQube. 85 | 86 | ![image](https://github.com/DevMadhup/node-todo-cicd/assets/121779953/54849cb2-fe56-4acd-972d-3057a0eb3deb) 87 | 88 | # 89 | 90 | 6) Go to Manage Jenkins , then tools , look for SonarQube Scanner installations and add SonarQube Scanner. 91 | 92 | > Note: Add name as ```Sonar``` 93 | 94 | ![image](https://github.com/DevMadhup/node-todo-cicd/assets/121779953/1fe926f6-a844-42d4-bce4-62193dde6640) 95 | 96 | 7) Integrate OWASP with Jenkins, go to Manage Jenkins , then tools , look for Dependency-Check installations and add Dependency-Check. 97 | 98 | > Note: Add name as ```dc``` 99 | 100 | ![image](https://github.com/DevMadhup/node-todo-cicd/assets/121779953/14516995-0c96-4110-bb96-97a37a9fe57d) 101 | 102 | # 103 | 104 | 8) For trivy, we have already installed it, in pre-reuisites. 105 | 106 | ![image](https://github.com/DevMadhup/node-todo-cicd/assets/121779953/0fcd1620-bd64-4286-bc13-f6652d4527c6) 107 | 108 | # 109 | 110 | 9) Now, It's time to create a CI/CD pipeline in Jenkins: 111 | - Click on New Item and give it a name and select Pipeline. 112 | - Select GitHub Project and paste your GitHub repository link. 113 | - Scroll down and in Pipeline section select Pipeline script from SCM, because our Jenkinsfile is present on GitHub. 114 | 115 | ![image](https://github.com/DevMadhup/node-todo-cicd/assets/121779953/39af1b22-28aa-4e36-b98c-0e7f120b5fbf) 116 | 117 | ![image](https://github.com/DevMadhup/node-todo-cicd/assets/121779953/b7153556-f847-40ee-9a98-ff3609930abd) 118 | # 119 | 120 | 10) At last run the pipeline and after sometime your code is deployed using DevSecOps. 121 | 122 | ![image](https://github.com/DevMadhup/node-todo-cicd/assets/121779953/f566d980-82ee-4ad6-9ff3-cb970885560e) 123 | # 124 | 125 | Congratulations!!! You have done it 126 | 127 | - If you find any issue during the execution of this project, let me know on LinkedIn 128 | 129 | - Happy Learning :) 130 | # 131 | 132 | ## These are our community Links 133 | 134 | 135 |   136 | 137 | 138 | 139 |   140 | 141 | 142 | 143 |   144 | 145 | 146 | 147 |   148 | 149 | 150 | 151 |   152 | 153 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Node Base Image 2 | FROM node:12.2.0-alpine 3 | 4 | #Working Directry 5 | WORKDIR /node 6 | 7 | #Copy the Code 8 | COPY . . 9 | 10 | #Install the dependecies 11 | RUN npm install 12 | RUN npm run test 13 | EXPOSE 8000 14 | 15 | #Run the code 16 | CMD ["node","app.js"] 17 | -------------------------------------------------------------------------------- /Jenkinsfile: -------------------------------------------------------------------------------- 1 | pipeline{ 2 | agent { label 'dev-server' } 3 | 4 | stages{ 5 | stage("Code Clone"){ 6 | steps{ 7 | echo "Code Clone Stage" 8 | git url: "https://github.com/LondheShubham153/node-todo-cicd.git", branch: "master" 9 | } 10 | } 11 | stage("Code Build & Test"){ 12 | steps{ 13 | echo "Code Build Stage" 14 | sh "docker build -t node-app ." 15 | } 16 | } 17 | stage("Push To DockerHub"){ 18 | steps{ 19 | withCredentials([usernamePassword( 20 | credentialsId:"dockerHubCreds", 21 | usernameVariable:"dockerHubUser", 22 | passwordVariable:"dockerHubPass")]){ 23 | sh 'echo $dockerHubPass | docker login -u $dockerHubUser --password-stdin' 24 | sh "docker image tag node-app:latest ${env.dockerHubUser}/node-app:latest" 25 | sh "docker push ${env.dockerHubUser}/node-app:latest" 26 | } 27 | } 28 | } 29 | stage("Deploy"){ 30 | steps{ 31 | sh "docker compose down && docker compose up -d --build" 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # node-todo-cicd 2 | 3 | Run these commands: 4 | 5 | 6 | `sudo apt install nodejs` 7 | 8 | 9 | `sudo apt install npm` 10 | 11 | 12 | `npm install` 13 | 14 | `node app.js` 15 | 16 | or Run by docker compose 17 | 18 | test 19 | 20 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | const express = require('express'), 2 | bodyParser = require('body-parser'), 3 | // In order to use PUT HTTP verb to edit item 4 | methodOverride = require('method-override'), 5 | // Mitigate XSS using sanitizer 6 | sanitizer = require('sanitizer'), 7 | app = express(), 8 | port = 8000 9 | 10 | app.use(bodyParser.urlencoded({ 11 | extended: false 12 | })); 13 | // https: //github.com/expressjs/method-override#custom-logic 14 | app.use(methodOverride(function (req, res) { 15 | if (req.body && typeof req.body === 'object' && '_method' in req.body) { 16 | // look in urlencoded POST bodies and delete it 17 | let method = req.body._method; 18 | delete req.body._method; 19 | return method 20 | } 21 | })); 22 | 23 | 24 | let todolist = []; 25 | 26 | /* The to do list and the form are displayed */ 27 | app.get('/todo', function (req, res) { 28 | res.render('todo.ejs', { 29 | todolist, 30 | clickHandler: "func1();" 31 | }); 32 | }) 33 | 34 | /* Adding an item to the to do list */ 35 | .post('/todo/add/', function (req, res) { 36 | // Escapes HTML special characters in attribute values as HTML entities 37 | let newTodo = sanitizer.escape(req.body.newtodo); 38 | if (req.body.newtodo != '') { 39 | todolist.push(newTodo); 40 | } 41 | res.redirect('/todo'); 42 | }) 43 | 44 | /* Deletes an item from the to do list */ 45 | .get('/todo/delete/:id', function (req, res) { 46 | if (req.params.id != '') { 47 | todolist.splice(req.params.id, 1); 48 | } 49 | res.redirect('/todo'); 50 | }) 51 | 52 | // Get a single todo item and render edit page 53 | .get('/todo/:id', function (req, res) { 54 | let todoIdx = req.params.id; 55 | let todo = todolist[todoIdx]; 56 | 57 | if (todo) { 58 | res.render('edititem.ejs', { 59 | todoIdx, 60 | todo, 61 | clickHandler: "func1();" 62 | }); 63 | } else { 64 | res.redirect('/todo'); 65 | } 66 | }) 67 | 68 | // Edit item in the todo list 69 | .put('/todo/edit/:id', function (req, res) { 70 | let todoIdx = req.params.id; 71 | // Escapes HTML special characters in attribute values as HTML entities 72 | let editTodo = sanitizer.escape(req.body.editTodo); 73 | if (todoIdx != '' && editTodo != '') { 74 | todolist[todoIdx] = editTodo; 75 | } 76 | res.redirect('/todo'); 77 | }) 78 | /* Redirects to the to do list if the page requested is not found */ 79 | .use(function (req, res, next) { 80 | res.redirect('/todo'); 81 | }) 82 | 83 | .listen(port, function () { 84 | // Logging to console 85 | console.log(`Todolist running on http://0.0.0.0:${port}`) 86 | }); 87 | // Export app 88 | module.exports = app; 89 | -------------------------------------------------------------------------------- /azure-pipelines.yml: -------------------------------------------------------------------------------- 1 | # Starter pipeline 2 | # Start with a minimal pipeline that you can customize to build and deploy your code. 3 | # Add steps that build, run tests, deploy, and more: 4 | # https://aka.ms/yaml 5 | 6 | trigger: 7 | - master 8 | 9 | pool: 10 | vmImage: ubuntu-latest 11 | 12 | steps: 13 | - script: echo Hello, world! 14 | displayName: 'Run a one-line script' 15 | 16 | - script: | 17 | echo Add other tasks to build, test, and deploy your project. 18 | echo See https://aka.ms/yaml 19 | displayName: 'Run a multi-line script' 20 | -------------------------------------------------------------------------------- /docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: '3.9' 2 | 3 | services: 4 | web: 5 | image: trainwithshubham/node-app:latest 6 | ports: 7 | - "8000:8000" 8 | -------------------------------------------------------------------------------- /k8s/deployment.yml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: node-app-deployment 5 | namespace: node-app 6 | labels: 7 | app: node-app 8 | spec: 9 | replicas: 2 10 | selector: 11 | matchLabels: 12 | app: node-app 13 | template: 14 | metadata: 15 | name: node-pod 16 | namespace: node-app 17 | labels: 18 | app: node-app 19 | spec: 20 | containers: 21 | - name: node-container 22 | image: trainwithshubham/node-app-batch-6 23 | ports: 24 | - containerPort: 8000 25 | resources: 26 | requests: 27 | memory: "64Mi" 28 | cpu: "250m" 29 | limits: 30 | memory: "128Mi" 31 | cpu: "500m" 32 | -------------------------------------------------------------------------------- /k8s/pod.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: node-pod 5 | namespace: node-app 6 | 7 | spec: 8 | containers: 9 | - name: node-container 10 | image: trainwithshubham/node-app-batch-6 11 | ports: 12 | - containerPort: 8000 13 | -------------------------------------------------------------------------------- /k8s/replica-sets.yml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: ReplicaSet 3 | metadata: 4 | name: node-app-replica-set 5 | namespace: node-app 6 | labels: 7 | app: guestbook 8 | tier: node-label 9 | spec: 10 | # modify replicas according to your case 11 | replicas: 6 12 | selector: 13 | matchLabels: 14 | tier: node-label 15 | template: 16 | metadata: 17 | namespace: node-app 18 | labels: 19 | tier: node-label 20 | spec: 21 | containers: 22 | - name: node-container-rep 23 | image: trainwithshubham/node-app-batch-6 24 | -------------------------------------------------------------------------------- /k8s/service.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: node-app-service 5 | namespace: node-app 6 | spec: 7 | type: NodePort 8 | selector: 9 | app: node-app 10 | ports: 11 | - port: 80 12 | targetPort: 8000 13 | nodePort: 30003 14 | -------------------------------------------------------------------------------- /kustomize/README.md: -------------------------------------------------------------------------------- 1 | # Google Kubernetes Engine (GKE) Autopilot and Kustomize 2 | 3 | Welcome to the NodeJS DevOps Project GitHub repository! This repository contains instructions and resources to help you get started with Google Kubernetes Engine (GKE) Autopilot and Google Cloud Shell. 4 | 5 | ## Table of Contents 6 | - [Introduction](#introduction) 7 | - [Prerequisites](#prerequisites) 8 | - [Getting Started](#getting-started) 9 | - [Install HELM](#install-helm) 10 | - [Install nginx-controller](#install-nginx-controller) 11 | - [Kubernetes Autopilot](#kubernetes-autopilot) 12 | - [Create a Namespace](#create-a-namespace) 13 | - [Deploy an Application](#deploy-an-application) 14 | - [Google Cloud Shell](#google-cloud-shell) 15 | - [Useful Commands](#useful-commands) 16 | 17 | ## Introduction 18 | This repository provides a step-by-step guide to setting up a Kubernetes environment with GKE Autopilot and using Google Cloud Shell for management and deployment tasks. 19 | 20 | ## Prerequisites 21 | Before you begin, make sure you have the following prerequisites: 22 | - A Google Cloud Platform (GCP) account with billing enabled. 23 | - Google Cloud SDK (gcloud) installed on your local machine. 24 | - Access to a GKE cluster with Autopilot enabled. 25 | 26 | 27 | # Google Cloud Shell 28 | Google Cloud Shell provides a browser-based shell environment that you can use for managing your GCP resources and interacting with Kubernetes clusters. 29 | 30 | To access Google Cloud Shell, follow these steps: 31 | 32 | Log in to your GCP Console. 33 | Click on the "Activate Cloud Shell" button in the upper-right corner. 34 | 35 | ### Install HELM 36 | To install HELM, use the following commands: 37 | 38 | ## Add & Update the HELM repository 39 | ```bash 40 | 41 | helm repo add helm https://helm.sh/helm 42 | 43 | helm repo update 44 | ``` 45 | ## Install nginx-controller 46 | To install the nginx-controller, use the following commands: 47 | 48 | ## Add & Update the nginx-controller repository 49 | ```bash 50 | helm repo add nginx https://kubernetes.github.io/ingress-nginx 51 | helm repo update 52 | helm install nginx nginx/ingress-nginx 53 | helm search repo nginx 54 | ``` 55 | ## List all ValidatingWebhookConfigurations in all namespaces 56 | ```bash 57 | kubectl get ValidatingWebhookConfiguration -A 58 | ``` 59 | ## Delete a ValidatingWebhookConfiguration (e.g., nginx-ingress-nginx-admission) 60 | ```bash 61 | kubectl delete -A ValidatingWebhookConfiguration nginx-ingress-nginx-admission 62 | ``` 63 | # On Shell 64 | ## Create a Namespace 65 | You can create a Kubernetes namespace using the following command: 66 | 67 | ``` bash 68 | kubectl create namespace 69 | ``` 70 | # Deploy an Application using Kustomize 71 | 72 | To deploy an application, apply the YAML configuration file to your namespace: 73 | 74 | ```bash 75 | 76 | kubectl apply -k 77 | ``` 78 | 79 | # Useful Commands 80 | Here are some useful commands to help you manage your Kubernetes environment: 81 | 82 | ``` bash= 83 | # List all pods in the current namespace 84 | kubectl get pods -n <>namespace> 85 | 86 | # Create a new Kubernetes namespace (e.g., "dev" or "sit") 87 | kubectl create ns 88 | 89 | # Apply a YAML configuration file to create resources 90 | kubectl apply -f 91 | ``` 92 | 93 | If you have any questions or encounter issues, please don't hesitate to open an issue or reach out to the community for assistance. 94 | 95 | Happy learning! 🚀 96 | -------------------------------------------------------------------------------- /kustomize/base/app-1/app-1.yml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | labels: 5 | app: app-1 6 | name: app-1-deployment 7 | namespace: default 8 | spec: 9 | replicas: 1 10 | selector: 11 | matchLabels: 12 | app: app-1 13 | template: 14 | metadata: 15 | labels: 16 | app: app-1 17 | spec: 18 | containers: 19 | - name: app-1-containter 20 | image: trainwithshubham/node-app-test-new:latest 21 | imagePullPolicy: Always 22 | --- 23 | apiVersion: v1 24 | kind: Service 25 | metadata: 26 | labels: 27 | app: app-1 28 | name: app-1-service 29 | namespace: default 30 | spec: 31 | type: NodePort 32 | ports: 33 | - name: webport 34 | port: 8000 35 | targetPort: 8000 36 | selector: 37 | app: app-1 38 | -------------------------------------------------------------------------------- /kustomize/base/app-1/kustomization.yml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | metadata: 4 | name: app-1-mapping 5 | 6 | resources: 7 | - app-1.yml 8 | -------------------------------------------------------------------------------- /kustomize/base/ingress/ingress.yml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.k8s.io/v1 2 | kind: Ingress 3 | metadata: 4 | name: app-ingress 5 | namespace: default 6 | spec: 7 | ingressClassName: "nginx" 8 | rules: 9 | - host: invalid.demo.trainwithshubham.com 10 | http: 11 | paths: 12 | - path: / 13 | pathType: Prefix 14 | backend: 15 | service: 16 | name: app-1-service 17 | port: 18 | number: 8000 19 | -------------------------------------------------------------------------------- /kustomize/base/ingress/kustomization.yml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | metadata: 4 | name: ingress-mapping 5 | 6 | resources: 7 | - ingress.yml 8 | -------------------------------------------------------------------------------- /kustomize/overlays/dev/dev-ingress-patch.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "op": "replace", 4 | "path": "/spec/rules/0/host", 5 | "value": "dev.demo.trainwithshubham.com" 6 | } 7 | ] 8 | -------------------------------------------------------------------------------- /kustomize/overlays/dev/kustomization.yml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | metadata: 4 | name: dev-mapping 5 | 6 | namespace: dev 7 | namePrefix: dev- 8 | replicas: 9 | - name: app-1-deployment 10 | count: 1 11 | 12 | resources: 13 | - ../../base/app-1/ 14 | - ../../base/ingress/ 15 | 16 | patches: 17 | - target: 18 | kind: Ingress 19 | name: app-ingress 20 | path: dev-ingress-patch.json 21 | -------------------------------------------------------------------------------- /kustomize/overlays/prd/kustomization.yml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | metadata: 4 | name: prd-mapping 5 | 6 | namespace: prd 7 | namePrefix: prd- 8 | 9 | replicas: 10 | - name: app-1-deployment 11 | count: 2 12 | 13 | resources: 14 | - ../../base/app-1/ 15 | - ../../base/ingress/ 16 | 17 | 18 | patches: 19 | - target: 20 | kind: Ingress 21 | name: app-ingress 22 | path: prd-ingress-patch.json 23 | -------------------------------------------------------------------------------- /kustomize/overlays/prd/prd-ingress-patch.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "op": "replace", 4 | "path": "/spec/rules/0/host", 5 | "value": "prd.demo.trainwithshubham.com" 6 | } 7 | ] 8 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-todolist", 3 | "version": "0.1.0", 4 | "dependencies": { 5 | "body-parser": "^1.16.0", 6 | "ejs": "^2.5.5", 7 | "express": "^4.14.0", 8 | "method-override": "^3.0.0", 9 | "sanitizer": "^0.1.3" 10 | }, 11 | "scripts": { 12 | "start": "node app.js", 13 | "test": "mocha --recursive --exit", 14 | "sonar": "sonar-scanner" 15 | }, 16 | "author": "riaan@entersekt.com", 17 | "description": "Basic to do list exercise", 18 | "devDependencies": { 19 | "chai": "^4.2.0", 20 | "mocha": "^6.2.1", 21 | "nyc": "^14.1.1", 22 | "supertest": "^4.0.2" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /sonar-project.properties: -------------------------------------------------------------------------------- 1 | # required metadata 2 | sonar.projectKey=node-todo-app 3 | sonar.projectName=Node application 4 | sonar.projectVersion=1.0.0 5 | 6 | # optional description 7 | sonar.projectDescription=This project demonstrates a simple node js. 8 | 9 | # path to source directories 10 | sonar.sources=./ 11 | 12 | # The value of the property must be the key of the language. 13 | sonar.language=js 14 | 15 | # Encoding of the source code 16 | sonar.sourceEncoding=UTF-8 17 | -------------------------------------------------------------------------------- /terraform/main.tf: -------------------------------------------------------------------------------- 1 | resource "docker_image" "todo_image" { 2 | name = "trainwithshubham/todo-app-node:latest" 3 | keep_locally = false 4 | } 5 | 6 | resource "docker_container" "todo_container" { 7 | image = docker_image.todo_image.name 8 | name = "todoapp-container" 9 | ports { 10 | internal = 8000 11 | external = 8000 12 | } 13 | 14 | depends_on = [ 15 | docker_image.todo_image 16 | ] 17 | 18 | } 19 | -------------------------------------------------------------------------------- /terraform/terraform.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_providers { 3 | docker = { 4 | source = "kreuzwerker/docker" 5 | version = "3.0.2" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | // Requiring module 2 | const assert = require('assert'); 3 | 4 | // We can group similar tests inside a describe block 5 | describe("Simple Calculations", () => { 6 | before(() => { 7 | console.log( "This part executes once before all tests" ); 8 | }); 9 | 10 | after(() => { 11 | console.log( "This part executes once after all tests" ); 12 | }); 13 | 14 | // We can add nested blocks for different tests 15 | describe( "Test1", () => { 16 | beforeEach(() => { 17 | console.log( "executes before every test" ); 18 | }); 19 | 20 | it("Is returning 5 when adding 2 + 3", () => { 21 | assert.equal(2 + 3, 5); 22 | }); 23 | 24 | it("Is returning 6 when multiplying 2 * 3", () => { 25 | assert.equal(2*3, 6); 26 | }); 27 | }); 28 | 29 | describe("Test2", () => { 30 | beforeEach(() => { 31 | console.log( "executes before every test" ); 32 | }); 33 | 34 | it("Is returning 4 when adding 2 + 3", () => { 35 | assert.equal(2 + 3, 5); 36 | }); 37 | 38 | it("Is returning 8 when multiplying 2 * 4", () => { 39 | assert.equal(2*4, 8); 40 | }); 41 | }); 42 | }); 43 | -------------------------------------------------------------------------------- /views/edititem.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Edit <%- todo %> 7 | 14 | 15 | 16 | 17 |

Edit <%- todo %>:

18 |
19 |

20 | 21 | 22 | 23 | 24 |

25 |
26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /views/todo.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Todo List APP test 5 | 89 | 90 | 91 | 92 |

Hello Junoon Batch 8 (Jenkins), Write your plan on Learning Jenkins

93 |
    94 | <% todolist.forEach(function(todo, index) { %> 95 |
  • 96 | 97 | 98 | <%- todo %> 99 |
  • 100 | <% }); %> 101 |
102 | 103 |
104 |

105 | 106 | 107 | 108 |

109 |
110 | 111 | 112 | --------------------------------------------------------------------------------