diff --git a/.github/workflows/main.yml b/.github/workflows/docker-publish.yml similarity index 78% rename from .github/workflows/main.yml rename to .github/workflows/docker-publish.yml index 7b3e1f7e..b9c0984f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/docker-publish.yml @@ -39,4 +39,11 @@ jobs: username: ${{ secrets.USERNAME }} password: ${{ secrets.PASSWORD }} port: ${{ secrets.PORT }} - script: kubectl get nodes + script: | + git clone -b ${{github.ref_name}} ${{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 + kubectl get all diff --git a/Jenkinsfile b/Jenkinsfile index 766f5d31..a170ada2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,27 +1,7 @@ -node(){ +@Library(["JenkinsSharedLibrary@main"]) _ - 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']]) - } - stage('Build Automation'){ - sh """ - ls -lart - mvn clean install - ls -lart target - - """ - } - - stage('Code Scan'){ - withSonarQubeEnv(credentialsId: 'SonarQubeCreds') { - sh "${sonarHome}/bin/sonar-scanner" - } - - } - - stage('Code Deployment'){ - deploy adapters: [tomcat9(credentialsId: 'TomcatCreds', path: '', url: 'http://54.197.62.94:8080/')], contextPath: 'Planview', onFailure: false, war: 'target/*.war' - } -} +mavenBuild( + gitURL : "https://github.com/anujdevopslearn/MavenBuild", + productType : "maven", + pomfileName : "pom.xml" +) 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/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 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