Skip to content

Commit 9c31f11

Browse files
committed
DevOps: Push DevOps-Project-06
* Implementation of the Entire Advanced CI/CD Pipeline with Major DevOps Tools Signed-off-by: NotHarshhaa <reddyharshhaa12@gmail.com>
1 parent e2be9ed commit 9c31f11

30 files changed

+1696
-0
lines changed

DevOps Project-06/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./target/*

DevOps Project-06/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM openjdk:8
2+
ADD jarstaging/com/satish/demo-workshop/2.1.2/demo-workshop-2.1.2.jar sample_app.jar
3+
ENTRYPOINT [ "java", "-jar", "sample_app.jar" ]

DevOps Project-06/Jenkinsfile

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
def registry = 'https://satishk.jfrog.io'
2+
def imageName = 'satishk.jfrog.io/satish-docker-local/sample_app'
3+
def version = '2.1.2'
4+
pipeline {
5+
agent {
6+
node {
7+
label 'maven'
8+
}
9+
}
10+
environment {
11+
PATH = "/opt/apache-maven-3.9.4/bin:$PATH"
12+
}
13+
stages {
14+
stage("build"){
15+
steps {
16+
echo "----------- build started ----------"
17+
sh 'mvn clean deploy -Dmaven.test.skip=true'
18+
echo "----------- build complted ----------"
19+
}
20+
}
21+
stage("test"){
22+
steps{
23+
echo "----------- unit test started ----------"
24+
sh 'mvn surefire-report:report'
25+
echo "----------- unit test Complted ----------"
26+
}
27+
}
28+
29+
stage('SonarQube analysis') {
30+
environment {
31+
scannerHome = tool 'satish-sonarqube-scanner'
32+
}
33+
steps{
34+
withSonarQubeEnv('satish-sonarqube-server') { // If you have configured more than one global server connection, you can specify its name
35+
sh "${scannerHome}/bin/sonar-scanner"
36+
}
37+
}
38+
}
39+
stage("Quality Gate"){
40+
steps {
41+
script {
42+
timeout(time: 1, unit: 'HOURS') { // Just in case something goes wrong, pipeline will be killed after a timeout
43+
def qg = waitForQualityGate() // Reuse taskId previously collected by withSonarQubeEnv
44+
if (qg.status != 'OK') {
45+
error "Pipeline aborted due to quality gate failure: ${qg.status}"
46+
}
47+
}
48+
}
49+
}
50+
}
51+
stage("Jar Publish") {
52+
steps {
53+
script {
54+
echo '<--------------- Jar Publish Started --------------->'
55+
def server = Artifactory.newServer url:registry+"/artifactory" , credentialsId:"jfrog_cred"
56+
def properties = "buildid=${env.BUILD_ID},commitid=${GIT_COMMIT}";
57+
def uploadSpec = """{
58+
"files": [
59+
{
60+
"pattern": "jarstaging/(*)",
61+
"target": "maven-libs-release-local/{1}",
62+
"flat": "false",
63+
"props" : "${properties}",
64+
"exclusions": [ "*.sha1", "*.md5"]
65+
}
66+
]
67+
}"""
68+
def buildInfo = server.upload(uploadSpec)
69+
buildInfo.env.collect()
70+
server.publishBuildInfo(buildInfo)
71+
echo '<--------------- Jar Publish Ended --------------->'
72+
73+
}
74+
}
75+
}
76+
77+
78+
stage(" Docker Build ") {
79+
steps {
80+
script {
81+
echo '<--------------- Docker Build Started --------------->'
82+
app = docker.build(imageName+":"+version)
83+
echo '<--------------- Docker Build Ends --------------->'
84+
}
85+
}
86+
}
87+
88+
stage (" Docker Publish "){
89+
steps {
90+
script {
91+
echo '<--------------- Docker Publish Started --------------->'
92+
docker.withRegistry(registry, 'jfrog_cred'){
93+
app.push()
94+
}
95+
echo '<--------------- Docker Publish Ended --------------->'
96+
}
97+
}
98+
}
99+
100+
// stage (" Deploy "){
101+
// steps {
102+
// script {
103+
// sh './deploy.sh'
104+
// }
105+
// }
106+
// }
107+
108+
stage(" Deploy ") {
109+
steps {
110+
script {
111+
echo '<--------------- Helm Deploy Started --------------->'
112+
sh 'helm install sample-app sample-app-1.0.1'
113+
echo '<--------------- Helm deploy Ends --------------->'
114+
}
115+
}
116+
}
117+
}
118+
}
119+
120+

DevOps Project-06/Project-06.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Implementation of the Entire Advanced CI/CD Pipeline with Major DevOps Tools
2+
3+
![devops](https://imgur.com/WcCpKVU.png)
4+
5+
### These are the steps I followed in the implementation of the entire CI/CD Pipeline.
6+
7+
1. [Provisioned the required infrastructure like VPC, Security Group, Ansible Controller Instance, Jenkins Master and Agent Instances using Terraform.](https://github.com/NotHarshhaa/DevOps-Projects/blob/master/DevOps%20Project-06/Steps/step1.md#L1)
8+
9+
2. [Configured SSH keys for password less authentication between Ansible Controller and Agent nodes.](https://github.com/NotHarshhaa/DevOps-Projects/blob/master/DevOps%20Project-06/Steps/step2.md#L1)
10+
11+
3. [Configured the Jenkins Master and Agent nodes using Ansible. Configured Jenkins Agent as the Maven Build server.](https://github.com/NotHarshhaa/DevOps-Projects/blob/master/DevOps%20Project-06/Steps/step3.md#L1)
12+
13+
4. [Added Jenkins Agent node's credentials in Jenkins Master to establish a connection between Jenkins Master and Agent nodes.](https://github.com/NotHarshhaa/DevOps-Projects/blob/master/DevOps%20Project-06/Steps/step4.md#L1)
14+
15+
5. [Added GitHub credentials to the Jenkins Master and created Multibranch Pipeline job.](https://github.com/NotHarshhaa/DevOps-Projects/blob/master/DevOps%20Project-06/Steps/step5.md#L1)
16+
17+
6. [Configured the Multibranch Pipeline job with GitHub Webhook Trigger with the help of Multibranch Scan Webhook Trigger Plugin.](https://github.com/NotHarshhaa/DevOps-Projects/blob/master/DevOps%20Project-06/Steps/step6.md#L1)
18+
19+
7. **SonarQube:**
20+
1. [Generated an access token in SonarCloud and added SonarQube server credentials in Jenkins Master.](https://github.com/NotHarshhaa/DevOps-Projects/blob/master/DevOps%20Project-06/Steps/step7.md#L3)
21+
2. [Installed Sonarqube scanner plugin.](https://github.com/NotHarshhaa/DevOps-Projects/blob/master/DevOps%20Project-06/Steps/step7.md#L64)
22+
3. [Added Sonarqube server to the Jenkins Master in System section.](https://github.com/NotHarshhaa/DevOps-Projects/blob/master/DevOps%20Project-06/Steps/step7.md#L100)
23+
4. [Added Sonarqube scanner to the Jenkins Master in Tools section.](https://github.com/NotHarshhaa/DevOps-Projects/blob/master/DevOps%20Project-06/Steps/step7.md#L140)
24+
5. [Configured an organization and project in SonarCloud and wrote a sonar-project. properties file.](https://github.com/NotHarshhaa/DevOps-Projects/blob/master/DevOps%20Project-06/Steps/step7.md#L174)
25+
6. [Added sonarqube, unit tests and build stages in the Jenkinsfile.](https://github.com/NotHarshhaa/DevOps-Projects/blob/master/DevOps%20Project-06/Steps/step7.md#L236)
26+
27+
8. [Added JFrog credentials in the Jenkins Master and integrated JFrog artifactory with Jenkins by installing Artifactory plugin in Jenkins Master.](https://github.com/NotHarshhaa/DevOps-Projects/blob/master/DevOps%20Project-06/Steps/step8.md#L1)
28+
29+
9. [Created a Docker Image out of the jar file and committed that Docker Image into the Docker repository of the JFrog artifactory with the help of Docker Pipeline plugin. Added the Docker Build and Publish stage in Jenkinsfile.](https://github.com/NotHarshhaa/DevOps-Projects/blob/master/DevOps%20Project-06/Steps/step9.md#L1)
30+
31+
10. **EKS:**
32+
1. [Provisioned the EKS cluster with Terraform.](https://github.com/NotHarshhaa/DevOps-Projects/blob/master/DevOps%20Project-06/Steps/step10.md#L3)
33+
2. [Installed kubectl in Jenkins Slave.](https://github.com/NotHarshhaa/DevOps-Projects/blob/master/DevOps%20Project-06/Steps/step10.md#L69)
34+
3. [Installed AWS CLI v2 in Jenkins Slave to connect with AWS account.](https://github.com/NotHarshhaa/DevOps-Projects/blob/master/DevOps%20Project-06/Steps/step10.md#L125)
35+
4. [Downloaded Kubernetes credentials and cluster configuration from the cluster using the command](https://github.com/NotHarshhaa/DevOps-Projects/blob/master/DevOps%20Project-06/Steps/step10.md#L181)
36+
5. `aws eks update-kubeconfig --region <region_name> --name <cluster_name>`
37+
38+
11. [Pulled the Docker Image from the JFrog artifactory using Kubernetes secret and deployed it in our EKS cluster using deployment resource and exposed it to access from outside using service resource under a particular namespace. Added the deployment stage in Jenkinsfile.](https://github.com/NotHarshhaa/DevOps-Projects/blob/master/DevOps%20Project-06/Steps/step11.md#L1)
39+
40+
12. [Added the Prometheus helm chart repository and implemented the cluster monitoring using Prometheus and Grafana.](https://github.com/NotHarshhaa/DevOps-Projects/blob/master/DevOps%20Project-06/Steps/step12.md#L1)
41+
* Note: Changed the default service type of Prometheus and Grafana services from ClusterIP to LoadBalancer to access them from the browser.
42+
---
43+
44+
# Hit the Star! ⭐
45+
***If you are planning to use this repo for learning, please hit the star. Thanks!***
46+
47+
#### Author by [Harshhaa Reddy](https://github.com/NotHarshhaa)
48+

DevOps Project-06/Steps/step1.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# About Step-01
2+
3+
This Steps used to Terraform to provision a set of infrastructure components including a VPC, Security Group, Ansible Controller Instance, and Jenkins Master and Agent Instances. This is a common approach to automate the deployment of infrastructure using code. Here's a breakdown of the components you've mentioned:
4+
5+
1. **VPC (Virtual Private Cloud):** A VPC is an isolated network environment within the cloud provider's infrastructure. It allows you to define your own IP address range, subnets, route tables, and network gateways. This helps you create a private and secure network for your resources.
6+
7+
2. **Security Group:** A security group acts as a virtual firewall for instances in a VPC. It controls inbound and outbound traffic by specifying rules. These rules define the allowed protocols, ports, and source/destination IP ranges. Security groups are used to enforce security policies on instances.
8+
9+
3. **Ansible Controller Instance:** This is an instance that is set up to run Ansible, an automation tool that helps you manage configuration and deployment tasks. The Ansible Controller Instance is where you'll typically run your Ansible playbooks to configure and manage other instances in your environment.
10+
11+
4. **Jenkins Master:** Jenkins is an open-source automation server that helps automate various parts of the software development process, including building, testing, and deploying applications. The Jenkins Master is the central server that manages jobs, schedules builds, and coordinates the activities of Jenkins Agents.
12+
13+
5. **Jenkins Agent Instances:** Jenkins Agents (also known as nodes) are responsible for executing the tasks and jobs scheduled by the Jenkins Master. They can be set up on different machines to distribute workloads and enable parallel execution of tasks.
14+
15+
Using Terraform to provision this infrastructure means that you've defined the configuration of these components in Terraform configuration files. These files specify the desired state of the infrastructure, and Terraform handles the provisioning, modification, and deletion of resources to match that desired state.
16+
17+
For future steps, you might want to consider the following:
18+
19+
1. **Configuration Management:** After provisioning the infrastructure, you would likely use Ansible to configure the instances. Ansible playbooks can define the desired state of the software and configurations on the Ansible Controller Instance and other instances.
20+
21+
2. **Integration with Jenkins:** You can configure Jenkins jobs to trigger Ansible playbooks or other automation tasks. This integration helps you automate the deployment and testing processes.
22+
23+
3. **Scaling and Maintenance:** As your application and infrastructure needs grow, you might need to scale up your resources. Terraform can help you manage scaling by defining the desired number of instances and other resources.
24+
25+
4. **Monitoring and Security:** Implement monitoring and security best practices to ensure that your infrastructure is performing well and is protected against potential threats.
26+
27+
Remember to regularly update your infrastructure code as your requirements evolve, and make use of version control systems to track changes and collaborate effectively with your team.

0 commit comments

Comments
 (0)