diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
deleted file mode 100644
index f02131ce..00000000
--- a/.github/workflows/ci.yml
+++ /dev/null
@@ -1,44 +0,0 @@
-name: Java CI with Gradle
-
-on:
- pull_request:
- branches: [ main ]
-
-env:
- DATREE_TOKEN: ${{ secrets.DATREE_TOKEN }}
-
-jobs:
- build:
-
- runs-on: ubuntu-latest
-
- steps:
- - uses: actions/checkout@v2
- - name: Set up JDK 11
- uses: actions/setup-java@v2
- with:
- java-version: '11'
- distribution: 'adopt'
- cache: gradle
- - name: Grant execute permission for gradlew
- run: chmod +x gradlew
- - name: Build with Gradle
- run: ./gradlew build
- - name: SonarQube Scan
- uses: sonarsource/sonarqube-scan-action@master
- env:
- SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
- - name: SonarQube Quality Gate check
- uses: sonarsource/sonarqube-quality-gate-action@master
- # Force to fail step after specific time
- timeout-minutes: 5
- env:
- SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- - name: Install Datree
- run: curl https://get.datree.io | /bin/bash
-
- - name: Run Datree's policy check
- run: datree test kube.yaml
-
-
diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml
deleted file mode 100644
index d6773d69..00000000
--- a/.github/workflows/cicd.yml
+++ /dev/null
@@ -1,84 +0,0 @@
-name: Java CICD with Gradle
-
-on:
- push:
- branches: [ main ]
-
-env:
- DATREE_TOKEN: ${{ secrets.DATREE_TOKEN }}
- KUBECONFIG: /home/alerts_deekshith/kubeconfig/config_now
-
-jobs:
- build:
-
- runs-on: self-hosted
-
- steps:
- - uses: actions/checkout@v2
- - name: Set up JDK 11
- uses: actions/setup-java@v2
- with:
- java-version: '11'
- distribution: 'adopt'
- cache: gradle
- - name: Grant execute permission for gradlew
- run: chmod +x gradlew
- - name: Build with Gradle
- run: ./gradlew build
- - name: SonarQube Scan
- uses: sonarsource/sonarqube-scan-action@master
- env:
- SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
- - name: SonarQube Quality Gate check
- uses: sonarsource/sonarqube-quality-gate-action@master
- # Force to fail step after specific time
- timeout-minutes: 5
- env:
- SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- - name: Install Datree
- run: curl https://get.datree.io | /bin/bash
-
- - name: Run Datree's policy check
- run: datree test kube.yaml
-
- - name: Login to Nexus registy
- uses: docker/login-action@v1
- with:
- registry: 34.125.31.157:8083
- username: ${{ secrets.DOCKERHUB_USERNAME }}
- password: ${{ secrets.DOCKERHUB_TOKEN }}
-
- - name: docker build & docker push
- run: |
- docker build -t 34.125.31.157:8083/javaapp:${{ github.run_number }} .
- docker push 34.125.31.157:8083/javaapp:${{ github.run_number }}
- docker rmi 34.125.31.157:8083/javaapp:${{ github.run_number }}
-
- - name: deploying manifest file on k8s cluster
- run: |
- sed -i "s;imagename;34.125.31.157:8083/javaapp:${{ github.run_number }};g" kube.yaml
- kubectl apply -f kube.yaml
- sleep 30
- kubectl get po
-
- - name: verification
- run: |
- sleep 60
- kubectl run curl --image=curlimages/curl -i --rm --restart=Never -- curl myapp:8080
-
- - name: Send email
- if: always()
- uses: dawidd6/action-send-mail@v2
- with:
- server_address: smtp.gmail.com
- server_port: 465
- username: ${{ secrets.EMAIL_USERNAME }}
- password: ${{ secrets.EMAIL_PASSWORD }}
- subject: ${{ github.job }} job of ${{ github.repository }} has ${{ job.status }}
- # email body as text
- body: ${{ github.job }} job in worflow ${{ github.workflow }} of ${{ github.repository }} has ${{ job.status }}
- # comma-separated string, send email to
- to: deekshith.snsep@gmail.com
- # from email name
- from: deekshith.snsep@gmail.com
diff --git a/Dockerfile b/Dockerfile
deleted file mode 100644
index f9c20863..00000000
--- a/Dockerfile
+++ /dev/null
@@ -1,11 +0,0 @@
-# this is multi stage
-FROM openjdk:11 as base
-WORKDIR /app
-COPY . .
-RUN chmod +x gradlew
-RUN ./gradlew build
-
-FROM tomcat:9
-WORKDIR webapps
-COPY --from=base /app/build/libs/sampleWeb-0.0.1-SNAPSHOT.war .
-RUN rm -rf ROOT && mv sampleWeb-0.0.1-SNAPSHOT.war ROOT.war
diff --git a/Jenkinsfile b/Jenkinsfile
deleted file mode 100644
index a2df42b1..00000000
--- a/Jenkinsfile
+++ /dev/null
@@ -1,112 +0,0 @@
-pipeline{
- agent any
- environment{
- VERSION = "${env.BUILD_ID}"
- }
- stages{
- stage("sonar quality check"){
- agent {
- docker {
- image 'openjdk:11'
- }
- }
- steps{
- script{
- withSonarQubeEnv(credentialsId: 'sonar-token') {
- sh 'chmod +x gradlew'
- sh './gradlew sonarqube'
- }
-
- 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_pass', variable: 'docker_password')]) {
- sh '''
- docker build -t 34.125.214.226:8083/springapp:${VERSION} .
- docker login -u admin -p $docker_password 34.125.214.226:8083
- docker push 34.125.214.226:8083/springapp:${VERSION}
- docker rmi 34.125.214.226:8083/springapp:${VERSION}
- '''
- }
- }
- }
- }
- stage('indentifying misconfigs using datree in helm charts'){
- steps{
- script{
-
- dir('kubernetes/') {
- withEnv(['DATREE_TOKEN=GJdx2cP2TCDyUY3EhQKgTc']) {
- sh 'helm datree test myapp/'
- }
- }
- }
- }
- }
- stage("pushing the helm charts to nexus"){
- steps{
- script{
- withCredentials([string(credentialsId: 'docker_pass', variable: 'docker_password')]) {
- dir('kubernetes/') {
- sh '''
- helmversion=$( helm show chart myapp | grep version | cut -d: -f 2 | tr -d ' ')
- tar -czvf myapp-${helmversion}.tgz myapp/
- curl -u admin:$docker_password http://34.125.214.226:8081/repository/helm-hosted/ --upload-file myapp-${helmversion}.tgz -v
- '''
- }
- }
- }
- }
- }
-
- 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: "deekshith.snsep@gmail.com";
- input(id: "Deploy Gate", message: "Deploy ${params.project_name}?", ok: 'Deploy')
- }
- }
- }
- }
-
- stage('Deploying application on k8s cluster') {
- steps {
- script{
- withCredentials([kubeconfigFile(credentialsId: 'kubernetes-config', variable: 'KUBECONFIG')]) {
- dir('kubernetes/') {
- sh 'helm upgrade --install --set image.repository="34.125.214.226:8083/springapp" --set image.tag="${VERSION}" myjavaapp myapp/ '
- }
- }
- }
- }
- }
-
- stage('verifying app deployment'){
- steps{
- script{
- withCredentials([kubeconfigFile(credentialsId: 'kubernetes-config', variable: 'KUBECONFIG')]) {
- sh 'kubectl run curl --image=curlimages/curl -i --rm --restart=Never -- curl myjavaapp-myapp:8080'
-
- }
- }
- }
- }
- }
-
- post {
- always {
- mail bcc: '', body: "
Project: ${env.JOB_NAME}
Build Number: ${env.BUILD_NUMBER}
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: "deekshith.snsep@gmail.com";
- }
- }
-}
diff --git a/JenkinsfileFilter b/JenkinsfileFilter
deleted file mode 100644
index 1c68c70e..00000000
--- a/JenkinsfileFilter
+++ /dev/null
@@ -1,23 +0,0 @@
-pipeline {
- agent {
- docker {
- image 'openjdk:11'
- }
- }
-
- stages {
- stage('Building') {
- steps {
- sh 'chmod +x gradlew'
- sh "./gradlew build | tee output.log"
- }
- }
- stage('Monitoring the logs') {
- steps {
- script {
- sh '! grep "Task" output.log'
- }
- }
- }
- }
-}
diff --git a/JenkinsfileSharedLibrary b/JenkinsfileSharedLibrary
deleted file mode 100644
index ebccd0ae..00000000
--- a/JenkinsfileSharedLibrary
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/env groovy
-
-@Library('shared-library@master') _ //master or whatever branch
-
-
-pipeline {
- agent {
- docker {
- image 'openjdk:11'
- }
- }
-
- stages {
- stage('Building') {
- steps {
- sh 'chmod +x gradlew'
- sh "./gradlew build "
- }
- }
- stage ('Check logs') {
- steps {
- filterLogs ('Task', 3)
- }
- }
- }
-}
diff --git a/Jenkinsfile_demo b/Jenkinsfile_demo
deleted file mode 100644
index 3db03236..00000000
--- a/Jenkinsfile_demo
+++ /dev/null
@@ -1,96 +0,0 @@
-pipeline{
- agent any
- environment{
- VERSION = "${env.BUILD_ID}"
- }
- stages{
- stage("sonar qube analysis"){
- agent{
- docker {
- image 'openjdk:11'
- }
- }
- steps{
- script{
- withSonarQubeEnv(credentialsId: 'sonar-token') {
- sh '''
- chmod +x gradlew
- ./gradlew sonarqube
- '''
- }
-
- timeout(5) {
- def qg = waitForQualityGate()
- if (qg.status != 'OK') {
- error "Pipeline aborted due to quality gate failure: ${qg.status}"
- }
- }
- }
- }
- }
-
- stage("building docker image and pushing it to nexus"){
- steps{
- script{
-
- withCredentials([string(credentialsId: 'nexus_pass', variable: 'docker_pass')]) {
- sh '''
-
- docker build -t 35.188.44.251:8083/springapp:${VERSION} .
- docker login -u admin -p $docker_pass 35.188.44.251:8083
- docker push 35.188.44.251:8083/springapp:${VERSION}
- docker rmi 35.188.44.251:8083/springapp:${VERSION}
- docker image prune -f
- '''
- }
- }
- }
- }
-
-
- 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: "issamraz1993@gmail.com";
- input(id: "Deploy Gate", message: "Deploy ${params.project_name}?", ok: 'Deploy')
- }
- }
- }
- }
-
-
-
- stage('Deploying application on k8s cluster') {
- steps {
- script{
- withCredentials([kubeconfigFile(credentialsId: 'kubernetes-config', variable: 'KUBECONFIG')]) {
- dir('kubernetes/') {
-
- sh 'helm upgrade --install --set image.repository="35.188.44.251:8083/springapp" --set image.tag="${VERSION}" myjavaapp myapp/ '
- }
- }
- }
- }
- }
-
-
- stage('verifying app deployment'){
- steps{
- script{
- withCredentials([kubeconfigFile(credentialsId: 'kubernetes-config', variable: 'KUBECONFIG')]) {
- sh '''
-
- chmod +x healthcheck.sh
- ./healthcheck.sh
- '''
-
- }
- }
- }
- }
-
-
- }
-
-}
diff --git a/healthcheck.sh b/healthcheck.sh
deleted file mode 100644
index c0244ee6..00000000
--- a/healthcheck.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-echo "executing health check it might take a while"
-sleep 120
-kubectl run curl --image=curlimages/curl -i --rm --restart=Never -- curl myjavaapp-myapp:8080
-
-if [ $? -eq 0 ]
-then
- echo "The Deployment is success...Application Health is Good"
-else
- helm rollback myjavaapp
-fi
diff --git a/kube.yaml b/kube.yaml
deleted file mode 100644
index d0058111..00000000
--- a/kube.yaml
+++ /dev/null
@@ -1,81 +0,0 @@
----
-apiVersion: v1
-kind: Service
-metadata:
- name: myapp
- labels:
- helm.sh/chart: myapp-0.2.0
- app.kubernetes.io/name: myapp
- app.kubernetes.io/instance: myapp
- app.kubernetes.io/version: "1.16.0"
- app.kubernetes.io/managed-by: Helm
-spec:
- type: NodePort
- ports:
- - port: 8080
- targetPort: http
- protocol: TCP
- name: http
- selector:
- app.kubernetes.io/name: myapp
- app.kubernetes.io/instance: myapp
----
-apiVersion: apps/v1
-kind: Deployment
-metadata:
- name: myapp
- labels:
- helm.sh/chart: myapp-0.2.0
- app.kubernetes.io/name: myapp
- app.kubernetes.io/instance: myapp
- app.kubernetes.io/version: "1.16.0"
- app.kubernetes.io/managed-by: Helm
-spec:
- replicas: 2
- selector:
- matchLabels:
- app.kubernetes.io/name: myapp
- app.kubernetes.io/instance: myapp
- template:
- metadata:
- labels:
- app.kubernetes.io/name: myapp
- app.kubernetes.io/instance: myapp
- spec:
- imagePullSecrets:
- - name: registry-secret
- containers:
- - name: myapp
- image: imagename
- command: ["/bin/sh"]
- args: ["-c","sh /usr/local/tomcat/bin/startup.sh;while true; do echo hello; sleep 10;done"]
- imagePullPolicy: IfNotPresent
- 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/.helmignore b/kubernetes/myapp/.helmignore
deleted file mode 100644
index 0e8a0eb3..00000000
--- a/kubernetes/myapp/.helmignore
+++ /dev/null
@@ -1,23 +0,0 @@
-# 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
deleted file mode 100644
index 3dd48d0b..00000000
--- a/kubernetes/myapp/Chart.yaml
+++ /dev/null
@@ -1,24 +0,0 @@
-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.2.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
deleted file mode 100644
index 73b52b22..00000000
--- a/kubernetes/myapp/templates/_helpers.tpl
+++ /dev/null
@@ -1,62 +0,0 @@
-{{/*
-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
deleted file mode 100644
index 2713adae..00000000
--- a/kubernetes/myapp/templates/deployment.yaml
+++ /dev/null
@@ -1,54 +0,0 @@
-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:
- imagePullSecrets:
- - name: registry-secret
- 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
deleted file mode 100644
index 61b409d5..00000000
--- a/kubernetes/myapp/templates/service.yaml
+++ /dev/null
@@ -1,15 +0,0 @@
-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: http
- protocol: TCP
- name: http
- selector:
- {{- include "myapp.selectorLabels" . | nindent 4 }}
diff --git a/kubernetes/myapp/values.yaml b/kubernetes/myapp/values.yaml
deleted file mode 100644
index a0e99a3a..00000000
--- a/kubernetes/myapp/values.yaml
+++ /dev/null
@@ -1,16 +0,0 @@
-# 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: 8080
-
diff --git a/sonar-project.properties b/sonar-project.properties
deleted file mode 100644
index 3f7e5334..00000000
--- a/sonar-project.properties
+++ /dev/null
@@ -1,3 +0,0 @@
-sonar.projectKey=CICD_Java_gradle_application
-sonar.java.binaries=.
-sonar.exclusions=build/**