From 31239ab66ad4eabf1dc677d3d00ac85408dda7d1 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 6 Jul 2023 18:57:18 +0000 Subject: [PATCH 01/21] Adding Helm Chart --- webapp/.helmignore | 23 +++++++++++++ webapp/Chart.yaml | 24 ++++++++++++++ webapp/templates/_helpers.tpl | 62 +++++++++++++++++++++++++++++++++++ webapp/values.yaml | 7 ++++ 4 files changed, 116 insertions(+) create mode 100644 webapp/.helmignore create mode 100644 webapp/Chart.yaml create mode 100644 webapp/templates/_helpers.tpl create mode 100644 webapp/values.yaml diff --git a/webapp/.helmignore b/webapp/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/webapp/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/webapp/Chart.yaml b/webapp/Chart.yaml new file mode 100644 index 00000000..ef5e1f74 --- /dev/null +++ b/webapp/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: webapp +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.16.0" diff --git a/webapp/templates/_helpers.tpl b/webapp/templates/_helpers.tpl new file mode 100644 index 00000000..db550e57 --- /dev/null +++ b/webapp/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "webapp.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "webapp.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "webapp.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "webapp.labels" -}} +helm.sh/chart: {{ include "webapp.chart" . }} +{{ include "webapp.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "webapp.selectorLabels" -}} +app.kubernetes.io/name: {{ include "webapp.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "webapp.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "webapp.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/webapp/values.yaml b/webapp/values.yaml new file mode 100644 index 00000000..71b4b99c --- /dev/null +++ b/webapp/values.yaml @@ -0,0 +1,7 @@ +image: + name: anujsharma1990/docker-image + tag: latest +replicascount: 2 +labels: + app: ais + tier: web From ee79b2f23cd1a5d2429a016caf50e7f94f7caac0 Mon Sep 17 00:00:00 2001 From: Anuj Sharma Date: Fri, 7 Jul 2023 01:10:11 +0530 Subject: [PATCH 02/21] Delete conditional.yml --- .github/workflows/conditional.yml | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 .github/workflows/conditional.yml diff --git a/.github/workflows/conditional.yml b/.github/workflows/conditional.yml deleted file mode 100644 index a0711568..00000000 --- a/.github/workflows/conditional.yml +++ /dev/null @@ -1,11 +0,0 @@ -name: Conditional Workflow Execution -on: [push] -jobs: - production-deploy: - if: github.ref_name == 'master' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: '14' From 76dbdc7d151ac9e7c69709a83e72957d6ed1a632 Mon Sep 17 00:00:00 2001 From: Anuj Sharma Date: Fri, 7 Jul 2023 13:38:24 +0530 Subject: [PATCH 03/21] Update and rename main.yml to docker-publish.yml --- .github/workflows/{main.yml => docker-publish.yml} | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) rename .github/workflows/{main.yml => docker-publish.yml} (89%) diff --git a/.github/workflows/main.yml b/.github/workflows/docker-publish.yml similarity index 89% rename from .github/workflows/main.yml rename to .github/workflows/docker-publish.yml index 7b3e1f7e..3f9e9431 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/docker-publish.yml @@ -39,4 +39,8 @@ jobs: username: ${{ secrets.USERNAME }} password: ${{ secrets.PASSWORD }} port: ${{ secrets.PORT }} - script: kubectl get nodes + script: | + helm list -A + helm install mavenbuild-dev ./webapp + helm list -A + kubectl get all From bf97f29729a9fedfda890e5daad2355f19b94124 Mon Sep 17 00:00:00 2001 From: Anuj Sharma Date: Fri, 7 Jul 2023 13:42:02 +0530 Subject: [PATCH 04/21] Update docker-publish.yml --- .github/workflows/docker-publish.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 3f9e9431..951962fa 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -40,6 +40,7 @@ jobs: password: ${{ secrets.PASSWORD }} port: ${{ secrets.PORT }} script: | + cd /github/workspace helm list -A helm install mavenbuild-dev ./webapp helm list -A From 2bc5a624cc84d1a5d63ac83330e60c21620603f2 Mon Sep 17 00:00:00 2001 From: Anuj Sharma Date: Fri, 7 Jul 2023 13:46:37 +0530 Subject: [PATCH 05/21] Update docker-publish.yml --- .github/workflows/docker-publish.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 951962fa..7b24a31c 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -40,7 +40,8 @@ jobs: password: ${{ secrets.PASSWORD }} port: ${{ secrets.PORT }} script: | - cd /github/workspace + ls -lart + pwd helm list -A helm install mavenbuild-dev ./webapp helm list -A From db4e982005cc34cf55c96b5c9f83bb988e6bd174 Mon Sep 17 00:00:00 2001 From: Anuj Sharma Date: Fri, 7 Jul 2023 13:56:49 +0530 Subject: [PATCH 06/21] Update docker-publish.yml --- .github/workflows/docker-publish.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 7b24a31c..aa8085fc 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -40,8 +40,7 @@ jobs: password: ${{ secrets.PASSWORD }} port: ${{ secrets.PORT }} script: | - ls -lart - pwd + git clone -b ${{ GITHUB_HEAD_REF }} ${{github.repository}} helm list -A helm install mavenbuild-dev ./webapp helm list -A From f8a17a914c7d676dd259381685d5f3851d1fe0ae Mon Sep 17 00:00:00 2001 From: Anuj Sharma Date: Fri, 7 Jul 2023 13:58:02 +0530 Subject: [PATCH 07/21] Update docker-publish.yml --- .github/workflows/docker-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index aa8085fc..94cc40b7 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -40,7 +40,7 @@ jobs: password: ${{ secrets.PASSWORD }} port: ${{ secrets.PORT }} script: | - git clone -b ${{ GITHUB_HEAD_REF }} ${{github.repository}} + git clone -b ${{ GITHUB_REF_NAME }} ${{github.repository}} helm list -A helm install mavenbuild-dev ./webapp helm list -A From 7604b3ba34ae96d30cebf25da6fdc69973ff5fcc Mon Sep 17 00:00:00 2001 From: Anuj Sharma Date: Fri, 7 Jul 2023 13:59:35 +0530 Subject: [PATCH 08/21] Update docker-publish.yml --- .github/workflows/docker-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 94cc40b7..f355dbf2 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -40,7 +40,7 @@ jobs: password: ${{ secrets.PASSWORD }} port: ${{ secrets.PORT }} script: | - git clone -b ${{ GITHUB_REF_NAME }} ${{github.repository}} + git clone -b develop ${{github.repository}} helm list -A helm install mavenbuild-dev ./webapp helm list -A From 029849416c1bded8b83a8e93b7db168acffb1e44 Mon Sep 17 00:00:00 2001 From: Anuj Sharma Date: Fri, 7 Jul 2023 14:01:38 +0530 Subject: [PATCH 09/21] Update docker-publish.yml --- .github/workflows/docker-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index f355dbf2..7f6fdd85 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -40,7 +40,7 @@ jobs: password: ${{ secrets.PASSWORD }} port: ${{ secrets.PORT }} script: | - git clone -b develop ${{github.repository}} + git clone -b develop https://github.com/${{github.repository}} helm list -A helm install mavenbuild-dev ./webapp helm list -A From e5945214af32d18f61cff8b6e1872ebfdf82b0b7 Mon Sep 17 00:00:00 2001 From: Anuj Sharma Date: Fri, 7 Jul 2023 14:03:15 +0530 Subject: [PATCH 10/21] Update docker-publish.yml --- .github/workflows/docker-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 7f6fdd85..44cc5222 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -40,7 +40,7 @@ jobs: password: ${{ secrets.PASSWORD }} port: ${{ secrets.PORT }} script: | - git clone -b develop https://github.com/${{github.repository}} + git clone -b develop https://github.com/${{github.repository}} . helm list -A helm install mavenbuild-dev ./webapp helm list -A From 5815cec44e687fa1b111269b959d1b9ad9835717 Mon Sep 17 00:00:00 2001 From: Anuj Sharma Date: Fri, 7 Jul 2023 14:07:08 +0530 Subject: [PATCH 11/21] Update docker-publish.yml --- .github/workflows/docker-publish.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 44cc5222..59e53879 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -41,6 +41,7 @@ jobs: port: ${{ secrets.PORT }} script: | git clone -b develop https://github.com/${{github.repository}} . + echo ${{ env.GITHUB_SERVER_URL }} helm list -A helm install mavenbuild-dev ./webapp helm list -A From 22c0b8b354626033e57a4da3085a9f363614ba05 Mon Sep 17 00:00:00 2001 From: Anuj Sharma Date: Fri, 7 Jul 2023 14:08:37 +0530 Subject: [PATCH 12/21] Update docker-publish.yml --- .github/workflows/docker-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 59e53879..0bd68668 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -41,7 +41,7 @@ jobs: port: ${{ secrets.PORT }} script: | git clone -b develop https://github.com/${{github.repository}} . - echo ${{ env.GITHUB_SERVER_URL }} + echo $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/ helm list -A helm install mavenbuild-dev ./webapp helm list -A From 414570ca8d3692469fbddc14b3427fd1e1c71161 Mon Sep 17 00:00:00 2001 From: Anuj Sharma Date: Fri, 7 Jul 2023 14:11:44 +0530 Subject: [PATCH 13/21] Update docker-publish.yml --- .github/workflows/docker-publish.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 0bd68668..28c07706 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -40,8 +40,9 @@ jobs: password: ${{ secrets.PASSWORD }} port: ${{ secrets.PORT }} script: | - git clone -b develop https://github.com/${{github.repository}} . - echo $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/ + git clone -b develop ${{github.server.url}}/${{github.repository}} + reponame=`echo ${{github.repository}}| cut -d'/' -f2` + cd $reponame helm list -A helm install mavenbuild-dev ./webapp helm list -A From a0603fad23ef2a65b9c135f75fd4afa28e7f4d63 Mon Sep 17 00:00:00 2001 From: Anuj Sharma Date: Fri, 7 Jul 2023 14:13:50 +0530 Subject: [PATCH 14/21] Update docker-publish.yml --- .github/workflows/docker-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 28c07706..b9c0984f 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -40,7 +40,7 @@ jobs: password: ${{ secrets.PASSWORD }} port: ${{ secrets.PORT }} script: | - git clone -b develop ${{github.server.url}}/${{github.repository}} + git clone -b ${{github.ref_name}} ${{github.server_url}}/${{github.repository}} reponame=`echo ${{github.repository}}| cut -d'/' -f2` cd $reponame helm list -A From 677d780ba574b69bdf0094a81999c9f75b34f117 Mon Sep 17 00:00:00 2001 From: Anuj Sharma Date: Fri, 7 Jul 2023 14:18:55 +0530 Subject: [PATCH 15/21] Create deployment.yaml --- webapp/templates/deployment.yaml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 webapp/templates/deployment.yaml diff --git a/webapp/templates/deployment.yaml b/webapp/templates/deployment.yaml new file mode 100644 index 00000000..5e73807f --- /dev/null +++ b/webapp/templates/deployment.yaml @@ -0,0 +1,28 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ais-ifm + labels: + app: ais +spec: + replicas: {{ .Values.replicascount }} + selector: + matchLabels: +{{toYaml .Values.labels | indent 6}} + template: + metadata: + labels: +{{toYaml .Values.labels | indent 8}} + spec: + containers: + - name: ais + image: {{ .Values.image.name }}:{{ .Values.image.tag }} + ports: + - containerPort: 8090 + resources: + limits: + cpu: 1000m + memory: 600Mi + requests: + cpu: 500m + memory: 300Mi From 269f8df897b59263ad6754f5bbf319a7cc2af8ae Mon Sep 17 00:00:00 2001 From: Anuj Sharma Date: Sun, 17 Dec 2023 20:52:50 +0530 Subject: [PATCH 16/21] Update Jenkinsfile --- Jenkinsfile | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 766f5d31..75bebd98 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,27 +1,22 @@ -node(){ - - def sonarHome = tool name: 'SonarScanner', type: 'hudson.plugins.sonar.SonarRunnerInstallation' - - stage('Code Checkout'){ - checkout changelog: false, poll: false, scm: scmGit(branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[credentialsId: 'GitHubCreds', url: 'https://github.com/anujdevopslearn/MavenBuild']]) +pipeline { + agent any +// agent { label "slave" } + environment { + gitURL="https://github.com/anujdevopslearn/MavenBuild.git" } - stage('Build Automation'){ - sh """ - ls -lart - mvn clean install - ls -lart target - - """ - } - - stage('Code Scan'){ - withSonarQubeEnv(credentialsId: 'SonarQubeCreds') { - sh "${sonarHome}/bin/sonar-scanner" + stages{ + stage("Code Checkout"){ + steps{ + git changelog: false, credentialsId: 'GitHubCreds', poll: false, url: gitURL + } + } + stage("Code Build"){ + steps{ + sh """ + ls -lart + mvn clean install + """ + } } - - } - - stage('Code Deployment'){ - deploy adapters: [tomcat9(credentialsId: 'TomcatCreds', path: '', url: 'http://54.197.62.94:8080/')], contextPath: 'Planview', onFailure: false, war: 'target/*.war' } } From 1511a734f90ad766ed7dc1558e9099bb577e8a34 Mon Sep 17 00:00:00 2001 From: Anuj Sharma Date: Sun, 17 Dec 2023 21:00:40 +0530 Subject: [PATCH 17/21] Update README.md From 4a2cd7f954a126e8db9cde75145ba41436524a55 Mon Sep 17 00:00:00 2001 From: Anuj Sharma Date: Sun, 17 Dec 2023 21:14:38 +0530 Subject: [PATCH 18/21] Update README.md From b023cec6cd1675cdfcef50bd7c51a8cdbee9db89 Mon Sep 17 00:00:00 2001 From: Anuj Sharma Date: Tue, 9 Apr 2024 16:10:29 +0530 Subject: [PATCH 19/21] Update Jenkinsfile --- Jenkinsfile | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 75bebd98..25706938 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,22 +1,7 @@ -pipeline { - agent any -// agent { label "slave" } - environment { - gitURL="https://github.com/anujdevopslearn/MavenBuild.git" - } - stages{ - stage("Code Checkout"){ - steps{ - git changelog: false, credentialsId: 'GitHubCreds', poll: false, url: gitURL - } - } - stage("Code Build"){ - steps{ - sh """ - ls -lart - mvn clean install - """ - } - } - } -} +@Library(["JenkinsSharedLibrary@main"]) _ + +mavenBuild( + gitURL = "https://github.com/anujdevopslearn/MavenBuild", + productType = "maven" + pomfileName = "pom.xml" +) From 6ed732c1036628979e63544fda0be5d846528f15 Mon Sep 17 00:00:00 2001 From: Anuj Sharma Date: Tue, 9 Apr 2024 16:16:56 +0530 Subject: [PATCH 20/21] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 25706938..340bb3e6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,6 +2,6 @@ mavenBuild( gitURL = "https://github.com/anujdevopslearn/MavenBuild", - productType = "maven" + productType = "maven", pomfileName = "pom.xml" ) From e113960eac29f7f07d46618cc829e45dbe5fe146 Mon Sep 17 00:00:00 2001 From: Anuj Sharma Date: Tue, 9 Apr 2024 16:18:33 +0530 Subject: [PATCH 21/21] Update Jenkinsfile --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 340bb3e6..a170ada2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,7 +1,7 @@ @Library(["JenkinsSharedLibrary@main"]) _ mavenBuild( - gitURL = "https://github.com/anujdevopslearn/MavenBuild", - productType = "maven", - pomfileName = "pom.xml" + gitURL : "https://github.com/anujdevopslearn/MavenBuild", + productType : "maven", + pomfileName : "pom.xml" )