diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 00000000..4ef7e3ac
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,4 @@
+FROM openjdk:11
+EXPOSE 8080
+ADD target/hello-world-0.0.1-SNAPSHOT.war hello-world-0.0.1-SNAPSHOT.war
+ENTRYPOINT ["java","-jar","/hello-world-0.0.1-SNAPSHOT.war"]
diff --git a/Jenkinsfile b/Jenkinsfile
deleted file mode 100644
index ad24bcc8..00000000
--- a/Jenkinsfile
+++ /dev/null
@@ -1,57 +0,0 @@
-pipeline {
- agent any
- tools {
- maven 'Maven'
- }
- stages {
- stage("Test"){
- steps{
- // mvn test
- sh "mvn test"
- slackSend channel: 'youtubejenkins', message: 'Job Started'
-
- }
-
- }
- stage("Build"){
- steps{
- sh "mvn package"
-
- }
-
- }
- stage("Deploy on Test"){
- steps{
- // deploy on container -> plugin
- deploy adapters: [tomcat9(credentialsId: 'tomcatserverdetails1', path: '', url: 'http://192.168.0.118:8080')], contextPath: '/app', war: '**/*.war'
-
- }
-
- }
- stage("Deploy on Prod"){
- input {
- message "Should we continue?"
- ok "Yes we Should"
- }
-
- steps{
- // deploy on container -> plugin
- deploy adapters: [tomcat9(credentialsId: 'tomcatserverdetails1', path: '', url: 'http://192.168.0.119:8080')], contextPath: '/app', war: '**/*.war'
-
- }
- }
- }
- post{
- always{
- echo "========always========"
- }
- success{
- echo "========pipeline executed successfully ========"
- slackSend channel: 'youtubejenkins', message: 'Success'
- }
- failure{
- echo "========pipeline execution failed========"
- slackSend channel: 'youtubejenkins', message: 'Job Failed'
- }
- }
-}
\ No newline at end of file
diff --git a/Readme.md b/Readme.md
index 8a0f4123..b021d87e 100644
--- a/Readme.md
+++ b/Readme.md
@@ -8,3 +8,8 @@
- mvn package
- apt-get install tomcat9
- cp -rvf target/hello-world-0.0.1-SNAPSHOT.war /var/lib/tomcat9/webapps/app.war
+- testing webhook
+testing weghook
+
+testing github web hook
+ghfvgfvgvgvgv
diff --git a/jenkinsfile b/jenkinsfile
new file mode 100644
index 00000000..dd0601f1
--- /dev/null
+++ b/jenkinsfile
@@ -0,0 +1,37 @@
+pipeline {
+ agent {
+ label 'java'
+ }
+
+ tools {
+ maven 'maven'
+ }
+
+ stages {
+ stage('git-checkout') {
+ steps {
+ checkout scmGit(branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/sudhakarbastawade2303/spring-boot-war-example.git']])
+ }
+ }
+ stage('Static Code Analysis') {
+ environment {
+ SONAR_URL = "http://65.2.11.163:9000"
+ }
+ steps {
+ withCredentials([string(credentialsId: 'sonar', variable: 'SONAR_AUTH_TOKEN')]) {
+ sh 'mvn sonar:sonar -Dsonar.login=$SONAR_AUTH_TOKEN -Dsonar.host.url=${SONAR_URL}'
+ }
+ }
+ }
+ stage('building-source-code') {
+ steps {
+ sh 'mvn clean package'
+ }
+ }
+ stage('deploy to tomcat') {
+ steps {
+ deploy adapters: [tomcat9(credentialsId: 'tomcat9-server', path: '', url: 'http://13.233.62.73:8080')], contextPath: '/app', war: '**/*.war'
+ }
+ }
+ }
+}
diff --git a/jenkinsfile-dockerpush b/jenkinsfile-dockerpush
new file mode 100644
index 00000000..807ecba6
--- /dev/null
+++ b/jenkinsfile-dockerpush
@@ -0,0 +1,50 @@
+pipeline {
+ agent any
+ tools {
+ maven 'maven'
+ }
+ environment {
+ VERSION = "${env.BUILD_ID}"
+ }
+ stages {
+ stage('SCM checkout') {
+ steps {
+ checkout scmGit(branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/sudhakarbastawade2303/spring-boot-war-example.git']])
+ }
+ }
+ // stage('Static Code Analysis') {
+ // environment {
+ // SONAR_URL = "http://65.2.11.163:9000"
+ // }
+ // steps {
+ // withCredentials([string(credentialsId: 'sonar', variable: 'SONAR_AUTH_TOKEN')]) {
+ // sh 'mvn sonar:sonar -Dsonar.login=$SONAR_AUTH_TOKEN -Dsonar.host.url=${SONAR_URL}'
+ // }
+ // }
+ // }
+ stage('Build war file'){
+ steps{
+ script{
+ sh 'mvn clean package'
+ }
+ }
+ }
+ stage("docker build & docker push"){
+ steps{
+ script{
+ withCredentials([string(credentialsId: 'dockerhub', variable: 'docker_password')]) {
+ sh '''
+ docker build -t sudhakarbastawade/testapp:${VERSION} .
+ docker login -u sudhakarbastawade -p ${docker_password}
+ docker push sudhakarbastawade/testapp:${VERSION}
+ docker rmi sudhakarbastawade/testapp:${VERSION}
+ '''
+ }
+ }
+ }
+ }
+
+
+
+ }
+}
diff --git a/jenkinsfile-k8s-deploy b/jenkinsfile-k8s-deploy
new file mode 100644
index 00000000..eeb48ab7
--- /dev/null
+++ b/jenkinsfile-k8s-deploy
@@ -0,0 +1,77 @@
+pipeline {
+ agent any
+ tools {
+ maven 'M2_HOME'
+ }
+ environment{
+ VERSION = "${env.BUILD_ID}"
+ }
+ stages {
+ stage('pull source code') {
+ steps {
+ checkout scmGit(branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/sudhakarbastawade2303/spring-boot-war-example.git']])
+ }
+ }
+ stage('Build') {
+ steps {
+ sh 'mvn clean package'
+ }
+ }
+ stage('Static Code Analysis') {
+ environment {
+ SONAR_URL = "http://52.205.251.40:9000"
+ }
+ steps {
+ script {
+ // withCredentials([string(credentialsId: 'sonar-token', variable: 'SONAR_AUTH_TOKEN')]) {
+ withSonarQubeEnv(credentialsId: 'sonar-token') {
+ sh 'mvn sonar:sonar -Dsonar.login=$SONAR_AUTH_TOKEN -Dsonar.host.url=${SONAR_URL}'
+ }
+ timeout(time: 1, unit: 'HOURS') {
+ def qg = waitForQualityGate()
+ if (qg.status != 'OK') {
+ error "Pipeline aborted due to quality gate failure: ${qg.status}"
+ }
+ }
+ }
+ }
+ }
+ stage("docker build & docker push"){
+ steps{
+ script{
+ withCredentials([string(credentialsId: 'docker', variable: 'docker_password')]) {
+ sh '''
+ docker build -t sudhakarbastawade/helm-deploy:${VERSION} .
+ docker login -u sudhakarbastawade -p $docker_password
+ docker push sudhakarbastawade/helm-deploy:${VERSION}
+ docker rmi sudhakarbastawade/helm-deploy:${VERSION}
+ '''
+ }
+ }
+ }
+ }
+ stage('manual approval'){
+ steps{
+ script{
+ timeout(10) {
+ mail bcc: '', body: "
Project: ${env.JOB_NAME}
Build Number: ${env.BUILD_NUMBER}
Go to build url and approve the deployment request
URL de build: ${env.BUILD_URL}", cc: '', charset: 'UTF-8', from: '', mimeType: 'text/html', replyTo: '', subject: "${currentBuild.result} CI: Project name -> ${env.JOB_NAME}", to: "devops.classes.online@gmail.com";
+ input(message: "Deploy ${params.project_name}?", ok: 'Deploy')
+ }
+ }
+ }
+ }
+ stage('Deploying application on k8s cluster') {
+ steps {
+ script{
+ // withCredentials([kubeconfigFile(credentialsId: 'kubeconfig', variable: 'KUBECONFIG')]) {
+ withCredentials([file(credentialsId: 'kubeconfig', variable: 'KUBECONFIG')]) {
+ dir('kubernetes/') {
+ sh 'helm upgrade --install --set image.repository="sudhakarbastawade/helm-deploy" --set image.tag="${VERSION}" myjavaapp myapp/ '
+ }
+ }
+ }
+ }
+ }
+
+ }
+}
diff --git a/kubernetes/myapp/.helmignore b/kubernetes/myapp/.helmignore
new file mode 100644
index 00000000..0e8a0eb3
--- /dev/null
+++ b/kubernetes/myapp/.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/kubernetes/myapp/Chart.yaml b/kubernetes/myapp/Chart.yaml
new file mode 100644
index 00000000..6fae50a4
--- /dev/null
+++ b/kubernetes/myapp/Chart.yaml
@@ -0,0 +1,24 @@
+apiVersion: v2
+name: myapp
+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/kubernetes/myapp/templates/_helpers.tpl b/kubernetes/myapp/templates/_helpers.tpl
new file mode 100644
index 00000000..73b52b22
--- /dev/null
+++ b/kubernetes/myapp/templates/_helpers.tpl
@@ -0,0 +1,62 @@
+{{/*
+Expand the name of the chart.
+*/}}
+{{- define "myapp.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 "myapp.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 "myapp.chart" -}}
+{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
+{{- end }}
+
+{{/*
+Common labels
+*/}}
+{{- define "myapp.labels" -}}
+helm.sh/chart: {{ include "myapp.chart" . }}
+{{ include "myapp.selectorLabels" . }}
+{{- if .Chart.AppVersion }}
+app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
+{{- end }}
+app.kubernetes.io/managed-by: {{ .Release.Service }}
+{{- end }}
+
+{{/*
+Selector labels
+*/}}
+{{- define "myapp.selectorLabels" -}}
+app.kubernetes.io/name: {{ include "myapp.name" . }}
+app.kubernetes.io/instance: {{ .Release.Name }}
+{{- end }}
+
+{{/*
+Create the name of the service account to use
+*/}}
+{{- define "myapp.serviceAccountName" -}}
+{{- if .Values.serviceAccount.create }}
+{{- default (include "myapp.fullname" .) .Values.serviceAccount.name }}
+{{- else }}
+{{- default "default" .Values.serviceAccount.name }}
+{{- end }}
+{{- end }}
diff --git a/kubernetes/myapp/templates/deployment.yaml b/kubernetes/myapp/templates/deployment.yaml
new file mode 100644
index 00000000..6419945d
--- /dev/null
+++ b/kubernetes/myapp/templates/deployment.yaml
@@ -0,0 +1,51 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: {{ include "myapp.fullname" . }}
+ labels:
+ {{- include "myapp.labels" . | nindent 4 }}
+spec:
+ replicas: {{ .Values.replicaCount }}
+ selector:
+ matchLabels:
+ {{- include "myapp.selectorLabels" . | nindent 6 }}
+ template:
+ metadata:
+ labels:
+ {{- include "myapp.selectorLabels" . | nindent 8 }}
+ spec:
+ containers:
+ - name: {{ .Chart.Name }}
+ image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
+ command: ["/bin/sh"]
+ args: ["-c","sh /usr/local/tomcat/bin/startup.sh;while true; do echo hello; sleep 10;done"]
+ imagePullPolicy: {{ .Values.image.pullPolicy }}
+ ports:
+ - name: http
+ containerPort: 8080
+ protocol: TCP
+ # livenessProbe:
+ # httpGet:
+ # path: /
+ # port: http
+ # initialDelaySeconds: 60
+ # periodSeconds: 5
+ # successThreshold: 1
+ # failureThreshold: 3
+ # timeoutSeconds: 10
+ # readinessProbe:
+ # httpGet:
+ # path: /
+ # port: http
+ # initialDelaySeconds: 60
+ # periodSeconds: 5
+ # successThreshold: 1
+ # failureThreshold: 3
+ # timeoutSeconds: 10
+ resources:
+ requests:
+ memory: 0.25Gi
+ cpu: 0.5
+ limits:
+ memory: 0.25Gi
+ cpu: 0.5
diff --git a/kubernetes/myapp/templates/service.yaml b/kubernetes/myapp/templates/service.yaml
new file mode 100644
index 00000000..e6c43e75
--- /dev/null
+++ b/kubernetes/myapp/templates/service.yaml
@@ -0,0 +1,15 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: {{ include "myapp.fullname" . }}
+ labels:
+ {{- include "myapp.labels" . | nindent 4 }}
+spec:
+ type: {{ .Values.service.type }}
+ ports:
+ - port: {{ .Values.service.port }}
+ targetPort: 8080
+ protocol: TCP
+ name: http
+ selector:
+ {{- include "myapp.selectorLabels" . | nindent 4 }}
diff --git a/kubernetes/myapp/values.yaml b/kubernetes/myapp/values.yaml
new file mode 100644
index 00000000..44203b0d
--- /dev/null
+++ b/kubernetes/myapp/values.yaml
@@ -0,0 +1,15 @@
+# Default values for myapp.
+# This is a YAML-formatted file.
+# Declare variables to be passed into your templates.
+
+replicaCount: 2
+
+image:
+ repository: IMAGE_NAME
+ pullPolicy: IfNotPresent
+ # Overrides the image tag whose default is the chart appVersion.
+ tag: IMAGE_TAG
+
+service:
+ type: NodePort
+ port: 80
diff --git a/pom.xml b/pom.xml
index 8909a32e..63ed7523 100644
--- a/pom.xml
+++ b/pom.xml
@@ -16,7 +16,6 @@
org.springframework.boot
spring-boot-starter-parent
2.3.2.RELEASE
-
@@ -44,7 +43,5 @@
spring-boot-maven-plugin
-
-
-
+
diff --git a/scripts/banner.txt b/scripts/banner.txt
deleted file mode 100644
index cb8ea3c3..00000000
--- a/scripts/banner.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-[38;5;44m [0m[38;5;44m [0m[38;5;44m [0m[38;5;44m [0m[38;5;44m [0m[38;5;44m_[0m[38;5;44m [0m[38;5;44m [0m[38;5;44m [0m[38;5;43m [0m[38;5;49m [0m[38;5;49m [0m[38;5;49m [0m[38;5;49m [0m[38;5;49m [0m[38;5;49m [0m[38;5;49m [0m[38;5;49m [0m[38;5;49m [0m[38;5;49m [0m[38;5;48m [0m[38;5;48m [0m[38;5;48m [0m[38;5;48m [0m
-[38;5;44m [0m[38;5;44m [0m[38;5;44m [0m[38;5;44m [0m[38;5;44m|[0m[38;5;44m [0m[38;5;43m|[0m[38;5;49m [0m[38;5;49m_[0m[38;5;49m_[0m[38;5;49m [0m[38;5;49m_[0m[38;5;49m_[0m[38;5;49m_[0m[38;5;49m [0m[38;5;49m [0m[38;5;49m [0m[38;5;48m_[0m[38;5;48m_[0m[38;5;48m_[0m[38;5;48m_[0m[38;5;48m [0m[38;5;48m_[0m[38;5;48m [0m
-[38;5;44m [0m[38;5;44m_[0m[38;5;44m [0m[38;5;43m [0m[38;5;49m|[0m[38;5;49m [0m[38;5;49m|[0m[38;5;49m/[0m[38;5;49m [0m[38;5;49m_[0m[38;5;49m`[0m[38;5;49m [0m[38;5;49m\[0m[38;5;49m [0m[38;5;48m\[0m[38;5;48m [0m[38;5;48m/[0m[38;5;48m [0m[38;5;48m/[0m[38;5;48m [0m[38;5;48m_[0m[38;5;48m`[0m[38;5;48m [0m[38;5;84m|[0m
-[38;5;43m|[0m[38;5;49m [0m[38;5;49m|[0m[38;5;49m_[0m[38;5;49m|[0m[38;5;49m [0m[38;5;49m|[0m[38;5;49m [0m[38;5;49m([0m[38;5;49m_[0m[38;5;49m|[0m[38;5;48m [0m[38;5;48m|[0m[38;5;48m\[0m[38;5;48m [0m[38;5;48mV[0m[38;5;48m [0m[38;5;48m/[0m[38;5;48m [0m[38;5;48m([0m[38;5;84m_[0m[38;5;83m|[0m[38;5;83m [0m[38;5;83m|[0m
-[38;5;49m [0m[38;5;49m\[0m[38;5;49m_[0m[38;5;49m_[0m[38;5;49m_[0m[38;5;49m/[0m[38;5;49m [0m[38;5;49m\[0m[38;5;48m_[0m[38;5;48m_[0m[38;5;48m,[0m[38;5;48m_[0m[38;5;48m|[0m[38;5;48m [0m[38;5;48m\[0m[38;5;48m_[0m[38;5;48m/[0m[38;5;84m [0m[38;5;83m\[0m[38;5;83m_[0m[38;5;83m_[0m[38;5;83m,[0m[38;5;83m_[0m[38;5;83m|[0m
-[38;5;49m [0m[38;5;49m [0m[38;5;49m [0m[38;5;49m [0m[38;5;49m [0m[38;5;48m [0m[38;5;48m [0m[38;5;48m [0m[38;5;48m [0m[38;5;48m [0m[38;5;48m [0m[38;5;48m [0m[38;5;48m [0m[38;5;48m [0m[38;5;84m [0m[38;5;83m [0m[38;5;83m [0m[38;5;83m [0m[38;5;83m [0m[38;5;83m [0m[38;5;83m [0m[38;5;83m [0m[38;5;83m [0m[38;5;83m [0m
-
diff --git a/scripts/utils.sh b/scripts/utils.sh
deleted file mode 100644
index be3f8d7d..00000000
--- a/scripts/utils.sh
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/bin/bash
-
-# will print the error code and return from script
-# will take two args.
-# 1 = error code
-# 2 = error message.
-
-. ./scripts/variables.sh
-
-function print_exit(){
- local error_code=${1}
- local error_msg=${2}
- echo -e "${RED}[Fail] ${error_msg} ${NOCOLOR}" 1>&2
- exit ${error_code}
-}
-
-function showBanner(){
- banner_file=${1}
- cat ${banner_file}
-}
-
-function showProgress(){
- local last_command_pid=${1}
- while ps | grep -i "${last_command_pid}" > /dev/null
- do
- for i in '-' '\' '|' '/'
- do
- echo -ne "\b${i}"
- sleep 0.20
- done
- echo -en "\b"
- done
-}
-
-function installPackage() {
- local packageName=${1}
- apt-get install -y ${packageName} > /dev/null &
- last_command_pid=$!
- showProgress ${last_command_pid}
- wait ${last_command_pid} || print_exit 1 "not able to install ${packageName}."
-}
-
-function mavenTarget(){
- local mavenCmd=${1}
- mvn ${mavenCmd} > /dev/null &
- last_command_pid=$!
- showProgress ${last_command_pid}
- wait ${last_command_pid} || print_exit 1 "${mavenCmd} fail."
-}
-
diff --git a/scripts/variables.sh b/scripts/variables.sh
deleted file mode 100644
index 0925862c..00000000
--- a/scripts/variables.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-# colors variables.
-RED='\033[0;31m'
-GREEN='\033[0;32m'
-NOCOLOR='\033[0m'
diff --git a/setup.sh b/setup.sh
index 0fc3c18c..f3d2d26f 100644
--- a/setup.sh
+++ b/setup.sh
@@ -52,4 +52,5 @@ fi
# Clean Up code.
clean_up
-exit 0
\ No newline at end of file
+exit 0
+
diff --git a/spring-boot-app-manifest/deployment.yaml b/spring-boot-app-manifest/deployment.yaml
new file mode 100644
index 00000000..25f84493
--- /dev/null
+++ b/spring-boot-app-manifest/deployment.yaml
@@ -0,0 +1,21 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: spring-boot-app
+ labels:
+ app: spring-boot-app
+spec:
+ replicas: 2
+ selector:
+ matchLabels:
+ app: spring-boot-app
+ template:
+ metadata:
+ labels:
+ app: spring-boot-app
+ spec:
+ containers:
+ - name: spring-boot-app
+ image: sudhakarbastawade/argo-cd:1
+ ports:
+ - containerPort: 8080
diff --git a/spring-boot-app-manifest/service.yaml b/spring-boot-app-manifest/service.yaml
new file mode 100644
index 00000000..400af546
--- /dev/null
+++ b/spring-boot-app-manifest/service.yaml
@@ -0,0 +1,13 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: spring-boot-app-service
+spec:
+ type: NodePort
+ ports:
+ - name: http
+ port: 80
+ targetPort: 8080
+ protocol: TCP
+ selector:
+ app: spring-boot-app
diff --git a/src/main/java/com/springhow/example/helloworld/HelloWorldApplication.java b/src/main/java/com/springhow/example/helloworld/HelloWorldApplication.java
index 349b44d1..3fb47b81 100644
--- a/src/main/java/com/springhow/example/helloworld/HelloWorldApplication.java
+++ b/src/main/java/com/springhow/example/helloworld/HelloWorldApplication.java
@@ -23,7 +23,7 @@ public static void main(String[] args) {
@RequestMapping("/")
String helloWorld() {
- return "5. please visit my website learning-ocean.com";
+ return "welcome to cloud-clasess";
}
}