Automating CI_CD for Deployment
Automating CI_CD for Deployment
Pipeline Workflow:
o ArgoCD detects changes in the repository and deploys the updated application
to Kubernetes.
LET’S START
Install Jenkins.
Pre-Requisites:
• Java (JDK)
Install Java
java -version
Now, you can proceed with installing Jenkins, Since it’s a Linux system, refer to Jenkins
documentation for installation commands
https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
**Note: ** By default, Jenkins will not be accessible to the external world due to the inbound
traffic restriction by AWS. Open port 8080 in the inbound traffic
Checking if Jenkins is running in ec2 instance
Once Jenkins is setup. Go to new items, here we’ll create a Jenkins pipeline
Here I am using the pipeline option
Referring to this Jenkins file, we’ll be using it. This file contains all the stages to be executed for
CI.
Jenkins clone the repo and search for the path where the Jenkinsfile is present, and it can have
any name. we are going to provide its path here
In comparison to it EC2 instances will require more configurations and will be costly as well
Now back to the ec2 instance, installing sonarqube server. By default it runs on port 9000. So
we’ll also add that in inbound rules.
adduser sonarqube
sudo su - sonarqube
wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-9.4.0.54424.zip
unzip *
cd sonarqube-9.4.0.54424/bin/linux-x86-64/
./sonar.sh start
Next step is to install docker on ec2. For it logout of sonarqube user and shift to root
sudo su -
Once you are done with the above steps, it is better to restart Jenkins.
http://54.80.16.178:8080/restart
For CD, here we are using k8s and its controller argo cd. We’ll be setting them on our host
machine, reason is: ec2 reources aren’t enough to deploy them on our instance
Analogy:
Think of the controller as the specific tool (Argo CD) performing a task and the operator as the
manager overseeing the tool’s health, upgrades, and configurations.
Here I am using docker as an agent, and in that image I have maven installation done
Secondly the stage 1, here in it as I have used SCM for Jenkins pipeline therefore I can simply
say its passed
Now setting up Jenkins to have connection with dockerhub and our repository(through )
As here for docker hub credentials are named as “docker-cred” therefore naming id the same
Now generate access token for github and connect github with Jenkins
Minikube start
docker login
push fizza05/maven-abhishek-docker-agent:v1
Sonarqube results
Now starting off with CD part. As argo cd operator’s installation is done. Now creating the argo
cd controller
Now we’ll pull the latest image from the git manifest repo
Since I want to run it on browser so Change the type from clusterip to nodeport
To execute it on browser use: minikube service argocd-server
To get the password of ARGOCD, use command: kubectl get secret, while username is: admin
from the example-argocd-cluster, copy the secret and decrypt it using base64
now provide the necessary info, provide it with the deployment.yaml file