Jenkins End-to-End Implementation
Jenkins End-to-End Implementation
IMPLEMENTAION
Goal:
Build a spring boot based Java application using Maven and deploy this
application on kubernetes using CICD
We accomplish this by adhering to the procedure outlined below, which integrates CI/CD
implementation at each stage
Activities in this project:
✓Build a Java application using Maven including configuration & installation
✓Setup a sonar server locally and send the report of code execution(static code analysis) to sonarqube
✓Build a docker image for the artifact and push it to dockerhub
✓Automatically update the manifest repository or source code repository using a shell script
✓Deploy the manifest automatically to a Kubernetes cluster using Argo CD
Step1:
Set up an EC2 instance in your AWS account, utilizing Ubuntu with an instance type of t2.large to
effectively utilize resources such as 2 CPUs and 8GB of memory, which are sufficient for this project
Checkout below video by Abhishek Veermalla , if you have any doubts on how to create EC2 instance.
https://youtu.be/MkIRh1mi8Ms?si=ZXblEOUZ3xw_jQZp
Checkout below github repo url where you can find code for this project
Note: Its created by Abhishek veermalla – creator of this project)
https://github.com/iam-veeramalla/Jenkins-Zero-To-Hero
Step2:
we have selected All traffic here ,but in real time environment restrict it as per your requirement.
❖Jenkins allows you to write your code in two ways , you can write under script section in Jenkins or
you can put your Jenkins file in git repo where your source code is available
❖ Usually in real time, organizations will manage the Jenkins file in same folder where your
application code is available i.e,. in Git repo
we have to give the Jenkins file path in your Jenkins configuration as below
The purpose of Jenkins file is to execute all the other tasks of the continuous integration.
➢We now need to install the Docker Pipeline plugin, which already includes Maven, located at the
following path
Dashboard -> manage Jenkins ->Plugins -> Available plugins -> Docker pipeline -> install without restart
➢To install sonar server, install sonar service under below path
Dashboard -> manage Jenkins -> Plugins -> Available Plugins ->SonarQubeScanner -> install without restart
use apt install unzip to install unzip package before downloading sonarqube
Checkout below Readme file where you have steps to install sonarqube
https://github.com/iam-veeramalla/Jenkins-Zero-To-Hero/blob/main/java-maven-sonar-argocd-helm-
k8s/spring-boot-app/README.md
Go to sonarqube -> my account-> security ->give token name as Jenkins and generate token
Copy the token, go to Jenkins -> click on Manage Jenkins ->credentials ->system ->global
credentials -> add credentials -> add sonarqube authentication here
❑Install Docker on your ec2-instance
Grant permissions to all users like Jenkins, ubuntu etc to avoid any permission issues
eg: http://100.24.255.244:8080/restart
▪ Now We have to configure docker credentials and github credentials inside jenkins
To get access key -> go to your github account -> settings -> developer settings ->personal access tokens-
>Tokens(classic) ->generate new token ->generate new token(classic)-> copy token to your jenkins
dashboard in same path(Dashboard=>Manage jenkins -> Credentials -> system-> global credentials)
Now restart jenkins as we did above configuration to get the changes reflected
➢ Create Container
➢ Checkout SCM
➢ Should push dockerhub image
➢ Should create sonarqube report
➢ Should update the image on dockerhub with build number automatically (shell script to update the
manifest folder)
Stage1: Creating container, Jenkins has to start creating a container and executing the container
Stage 2:
Docker image has to be created which will be configured in your jenkins file
with the same name, image should get created on docker hub
Stage 5:
https://minikube.sigs.k8s.io/docs/start/
https://argocd-operator.readthedocs.io/en/latest/usage/basics/
❖ To create argocd controller , create vi file with below example(mentioned in above doc )
minikube service list -> lists all the services exposed by minikube
minikube service example-argocd-server -> to expose specific service
In case if tunneling is not happening use below command
Tunneling in Minikube enables access to Kubernetes cluster services from the host machine
by forwarding traffic through a secure channel. It facilitates seamless interaction with
applications and services running within the cluster for development and testing purposes
Now you should be able to login argocd ui on your browser
Click on create application tab and start creating your first application☺
Click on create, you will see that application will be automatically created using kubernetes cluster as
argocd will fetch your application info from github repo
You can use below command to check whether the application is deployed