The e-commerce project is an integration with AWS Infrastructure and microservice application written in Java, we are using Spring Boot Develop API to retrieve data from Client to save data into AWS Aurora database, retrieve data from database to return to customer and update existing data, delete data, and more.
There is project structure:
Refer my Github reposittory: https://github.com/daotq2000/aws-spring-sqs-queue.git
In this pipeline project, we will complete these categories:
To get ECR push command, we are follow these step:
Using pipeline below:
def isJava = true;
// git repo
def gitUrl = 'git@github.com:daotq2000/aws-spring-sqs-queue.git'
def gitBranch = 'main'
// project
def projectGroup = 'aws'
def projectName = "aws-zero-downtime"
def namespace = "ciaws"
def helmValues = "project-values/aws-zero-down-time/values-dev.yaml"
/// DO NOT CHANGE BELOW
// key login
def gitCredential = 'jenkins-git'
def deployDirectory = '/var/lib/jenkins/workspace/AWS/AWS-DEV/helm-values/helm-values'
def mavenBuild = 'echo 1'
dockerBuildCommand = './'
def version = 'dev-0.0.${BUILD_NUMBER}'
if (isJava == true) {
mavenBuild = '/bin/bash ./mvnw -DskipTests clean package'
}
pipeline {
agent any
tools {
jdk 'jdk11'
}
environment {
DOCKER_REGISTRY = 'https://846338211683.dkr.ecr.us-east-1.amazonaws.com'
DOCKER_IMAGE_NAME = "eks-project"
DOCKER_IMAGE = "846338211683.dkr.ecr.us-east-1.amazonaws.com/${DOCKER_IMAGE_NAME}"
}
stages {
// stage('Update helm value') {
// steps {
// build job: "AWS/AWS-DEV/helm-values", wait: true
// }
// }
stage('Checkout project') {
steps {
git branch: gitBranch,
credentialsId: gitCredential,
url: gitUrl
}
}
stage('Build And Push Docker Image') {
steps {
script {
sh "git reset --hard"
sh "git clean -f"
sh "${mavenBuild}"
sh "aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 846338211683.dkr.ecr.us-east-1.amazonaws.com"
sh "docker build -t ${DOCKER_IMAGE_NAME}:${version} ./"
sh "docker tag ${DOCKER_IMAGE_NAME}:${version} ${DOCKER_IMAGE}:${version}"
sh "docker push ${DOCKER_IMAGE}:${version}"
sh "docker rmi ${DOCKER_IMAGE_NAME}:${version} -f"
sh "docker rmi ${DOCKER_IMAGE}:${version} -f"
}
}
}
stage('Apply k8s') {
steps {
script {
sh "helm upgrade $projectName $deployDirectory/chart-template/ -f $deployDirectory/$helmValues --namespace=$namespace -i --atomic --cleanup-on-fail --wait --timeout=5m --set fullnameOverride=$projectName,image.repository=${DOCKER_IMAGE},image.tag=${version}"
}
}
}
}
}
After done all, we have received result below:
[Install K9s] (https://github.com/derailed/k9s) After done, we can monitoring kubernetes cluster any where.