Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kubernetes setup #36

Open
wants to merge 39 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
c25c963
jenkins userdata
devopshydclub Jul 1, 2023
1dc4db6
Update nexus-setup.sh
hkhcoder Jul 1, 2023
c757e03
Update pom.xml
hkhcoder Oct 16, 2023
d98cb9e
Create settings.xml
hkhcoder Oct 16, 2023
0f8fd84
Update pom.xml
hkhcoder Nov 3, 2023
cd14391
Update pom.xml
hkhcoder Nov 3, 2023
1bf05e3
test commit to ci-jenkins branch
davismatrix May 10, 2024
faa2d40
including build job
davismatrix May 10, 2024
7ad5a3e
fix error on Jenkinsfile
davismatrix May 10, 2024
a646c1b
fixed variables on settings
davismatrix May 10, 2024
e311a17
another changes to settings.xml file
davismatrix May 10, 2024
fbeffab
Updated pipeline with unit test and code analysis
davismatrix May 11, 2024
c1cc598
Updated maven settings
davismatrix May 11, 2024
b050357
sonar reports upload
davismatrix May 11, 2024
8da4765
Sonar qualitygates
davismatrix May 11, 2024
5ba78d4
upload artifact to nexus code
davismatrix May 11, 2024
a0bae5b
fix uplaod artifact code
davismatrix May 11, 2024
dbe3c26
Slack notification system added
davismatrix May 11, 2024
78628b2
fixed syntex error
davismatrix May 11, 2024
cda32a3
Slack notification testing
davismatrix May 11, 2024
08ab64e
fixed syntax error
davismatrix May 11, 2024
87f9762
preparing cicd branch
davismatrix May 11, 2024
1c22076
add Docker files and updated Jenkinsfile
davismatrix May 11, 2024
1c8aea5
fixed multistage Dockerfile
davismatrix May 11, 2024
ec27c11
changed branck on build image to docker branch
davismatrix May 11, 2024
e236a11
Update Dockerfile
davismatrix May 11, 2024
1daba8d
changed branch to cicd-jenkins in build job
davismatrix May 11, 2024
d180e6b
fixed dockerfile
davismatrix May 11, 2024
0533ae3
another fix
davismatrix May 12, 2024
cedd497
another fix and test
davismatrix May 12, 2024
48b65e0
deploy to ecs staging
davismatrix May 12, 2024
f644791
fixed pipeline ecs deployment code
davismatrix May 12, 2024
2913014
fix deployment to ecs
davismatrix May 12, 2024
c512aa6
another fix
davismatrix May 12, 2024
7249c3b
changing ecs deplyment environment
davismatrix May 12, 2024
c7c4f1d
change deployment environment to stage
davismatrix May 12, 2024
baeaf1c
Prod ECS Pipeline
davismatrix May 13, 2024
4c56d9d
fixed stage and prod jenkinsfile
davismatrix May 13, 2024
5663cdd
new branch kubernetes-setup
davismatrix May 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Docker-files/app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ROM openjdk:8 AS BUILD_IMAGE
RUN apt update && apt install maven -y
RUN git clone https://github.com/davismatrix/vprofile-project.git
RUN cd vprofile-project && git checkout docker && mvn install

FROM tomcat:9-jre11

RUN rm -rf /usr/local/tomcat/webapps/*
COPY --from=BUILD_IMAGE vprofile-project/target/vprofile-v2.war /usr/local/tomcat/webapps/ROOT.war

EXPOSE 8080
CMD [ "catalina.sh", "run" ]
13 changes: 13 additions & 0 deletions Docker-files/app/multistage/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM openjdk:8 AS BUILD_IMAGE
RUN apt update && apt install maven -y
RUN git clone https://github.com/davismatrix/vprofile-project.git
RUN cd vprofile-project && git checkout docker && mvn install

FROM tomcat:9-jre11

RUN rm -rf /usr/local/tomcat/webapps/*
COPY --from=BUILD_IMAGE vprofile-project/target/vprofile-v2.war /usr/local/tomcat/webapps/ROOT.war

EXPOSE 8080
CMD [ "catalina.sh", "run" ]

Empty file added Docker-files/db/Dockerfile
Empty file.
Empty file added Docker-files/web/Dockerfile
Empty file.
121 changes: 0 additions & 121 deletions Jenkinsfile

This file was deleted.

37 changes: 37 additions & 0 deletions ProdPipeline/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
def COLOR_MAP = [
'SUCCESS': 'good',
'FAILURE': 'danger',
]
pipeline {
agent any
tools {
maven "MAVEN3"
jdk "OracleJDK8"
}

environment {

cluster = "vproprod"
service = "vproappprodsvc"
}

stages {

stage('Deploy to ECS PROD') {
steps {
withAWS(credentials: 'awscreds', region: 'ca-central-1') {
sh 'aws ecs update-service --cluster ${cluster} --service ${service} --force-new-deployment'
}
}
}
}

post {
always {
echo 'Slack Notification.'
slackSend channel: '#vappcicd',
color: COLOR_MAP[currentBuild.currentResult],
message: "*${currentBuild.currentResult}:* Job ${env.JOB_NAME} build ${env.BUILD_NUMBER} \n Job build took ${currentBuild.durationString} \n More info at: ${env.BUILD_URL}"
}
}
}
140 changes: 140 additions & 0 deletions StagePipeline/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
def COLOR_MAP = [
'SUCCESS': 'good',
'FAILURE': 'danger',
]
pipeline {
agent any
tools {
maven "MAVEN3"
jdk "OracleJDK8"
}

environment {
SNAP_REPO = 'vprofile-snapshot'
NEXUS_USER = 'admin'
NEXUS_PASS = 'admin1234'
RELEASE_REPO = 'vprofile-release'
CENTRAL_REPO = 'vpro-maven-central'
NEXUSIP = '192.168.56.14'
NEXUSPORT = '8081'
NEXUS_GRP_REPO = 'vpro-maven-group'
NEXUS_LOGIN = 'nexuslogin'
SONARSERVER = 'sonarserver'
SONARSCANNER = 'sonarscanner'
registryCredential = 'ecr:ca-central-1:awscreds'
appRegistry = '310358171212.dkr.ecr.ca-central-1.amazonaws.com/vprofileappimg'
vprofileRegistry = 'https://310358171212.dkr.ecr.ca-central-1.amazonaws.com'
cluster = "vprostaging"
service = "vproappstagesvc"
}

stages {
stage('build') {
steps {
sh 'mvn -s settings.xml -DskipTests install'
}
post {
success {
echo "Now Archiving."
archiveArtifacts artifacts: '**/*.war'
}
}
}

stage('Test') {
steps {
sh 'mvn -s settings.xml test'
}
}

stage('Checkstyle Analysis') {
steps {
sh 'mvn -s settings.xml checkstyle:checkstyle'
}
}

stage('Sonar Analysis') {
environment {
scannerHome = tool "${SONARSCANNER}"
}
steps {
withSonarQubeEnv("${SONARSERVER}") {
sh '''${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=vprofile \
-Dsonar.projectName=vprofile \
-Dsonar.projectVersion=1.0 \
-Dsonar.sources=src/ \
-Dsonar.java.binaries=target/test-classes/com/visualpathit/account/controllerTest/ \
-Dsonar.junit.reportsPath=target/surefire-reports/ \
-Dsonar.jacoco.reportsPath=target/jacoco.exec \
-Dsonar.java.checkstyle.reportPaths=target/checkstyle-result.xml'''
}
}
}

stage('Quality Gate') {
steps {
timeout(time: 1, unit: 'HOURS') {
// Parameter indicates whether to set pipeline to UNSTABLE
// true = set pipeline to UNSTABLE, false = don't
waitForQualityGate abortPipeline: true
}
}
}

stage ('UploadArtifact') {
steps {
nexusArtifactUploader(
nexusVersion: 'nexus3',
protocol: 'http',
nexusUrl: "${NEXUSIP}:${NEXUSPORT}",
groupId: 'QA',
version: "${env.BUILD_ID}-${env.BUILD_TIMESTAMP}",
repository: "${RELEASE_REPO}",
credentialsId: "${NEXUS_LOGIN}",
artifacts: [
[artifactId: 'vproapp',
classifier: '',
file: 'target/vprofile-v2.war',
type: 'war']
]
)
}
}

stage('Build App Image') {
steps {
script {
dockerImage = docker.build( appRegistry + ":$BUILD_NUMBER", "./Docker-files/app/multistage/" )
}
}
}

stage('Upload App Image') {
steps {
script {
docker.withRegistry( vprofileRegistry, registryCredential) {
dockerImage.push("$BUILD_NUMBER")
dockerImage.push('latest')
}
}
}
}

stage('Deploy to ECS staging') {
steps {
withAWS(credentials: 'awscreds', region: 'ca-central-1') {
sh 'aws ecs update-service --cluster ${cluster} --service ${service} --force-new-deployment'
}
}
}
}

post {
always {
echo 'Slack Notification.'
slackSend channel: '#vappcicd',
color: COLOR_MAP[currentBuild.currentResult],
message: "*${currentBuild.currentResult}:* Job ${env.JOB_NAME} build ${env.BUILD_NUMBER} \n Job build took ${currentBuild.durationString} \n More info at: ${env.BUILD_URL}"
}
}
}
55 changes: 55 additions & 0 deletions kubeadm/Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
Vagrant.configure("2") do |config|
config.hostmanager.enabled = true
config.hostmanager.manage_host = true
config.vm.define "kops" do |kops|
kops.vm.box = "ubuntu/bionic64"
kops.vm.network "private_network", ip: "192.168.56.2"
kops.vm.provider "virtualbox" do |vb|
vb.name = "kops"
vb.memory = 2048
vb.cpus = 2
end
kops.vm.hostname = "kops"
#kops.vm.provision "shell", path: "kubemaster-init.sh"
end

# config.vm.define "kubemaster" do |kubemaster|
# kubemaster.vm.box = "ubuntu/bionic64"
# kubemaster.vm.network "private_network", ip: "192.168.56.2"
# kubemaster.vm.provider "virtualbox" do |vb|
# vb.name = "kubemaster"
# vb.memory = 2048
# vb.cpus = 2
# end
# kubemaster.vm.hostname = "kubemaster"
# kubemaster.vm.provision "shell", path: "kubemaster-init.sh"
# end

#config.hostmanager.enabled = true
#config.hostmanager.manage_host = true
#config.vm.define "kubenode1" do |kubenode1|
# kubenode1.vm.box = "ubuntu/bionic64"
# kubenode1.vm.network "private_network", ip: "192.168.56.3"
# kubenode1.vm.provider "virtualbox" do |vb|
# vb.name = "kubenode1"
# vb.memory = 2048
# vb.cpus = 2
# end
# kubenode1.vm.hostname = "kubenode1"
# kubenode1.vm.provision "shell", path: "kubenode1-init.sh"
# end

# config.hostmanager.enabled = true
# config.hostmanager.manage_host = true
# config.vm.define "kubenode2" do |kubenode2|
# kubenode2.vm.box = "ubuntu/bionic64"
# kubenode2.vm.network "private_network", ip: "192.168.56.3"
# kubenode2.vm.provider "virtualbox" do |vb|
# vb.name = "kubenode2"
# vb.memory = 2048
# vb.cpus = 2
# end
# kubenode2.vm.hostname = "kubenode2"
# kubenode2.vm.provision "shell", path: "kubenode2-init.sh"
# end
end
Empty file added kubeadm/cltjoincommand.sh
Empty file.
Loading