Comprehensive DevOps Task
Comprehensive DevOps Task
Phase-1:
Jenkins Setup
1.Create an EC2 instance in public subnet
2. Install AWS CLI
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o
"awscliv2.zip"
sudo apt install unzip
unzip awscliv2.zip
sudo ./aws/install
aws configure
3. Install java17
sudo apt update
sudo apt install fontconfig openjdk-17-jre
java -version
openjdk version "17.0.8" 2023-07-18
OpenJDK Runtime Environment (build 17.0.8+7-Debian-1deb12u1)
OpenJDK 64-Bit Server VM (build 17.0.8+7-Debian-1deb12u1, mixed mode, sharing)
4.Install Jenkins
sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \
https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
echo "deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc]" \
https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
/etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt-get update
sudo apt-get install jenkins
sudo systemctl enable Jenkins
sudo systemctl start jenkins
sudo systemctl status jenkins
10. Create a Record for Application Load Balancer and generate SSL/TLS Certificate for the domain name.
11. Add the HTTPS Listener and attach the generated Certificate and also modify the HTTP listener to
redirect the Traffic to HTTPS.
12. Now Access the Jenkins using the domain name <jenkins.madhumadeep.world>
Phase-2:
Create VPC, Subnets, Routes, Internet Gateway, EC2 Instances, Security Groups:
Github Repo: https://github.com/Madeep9347/test-project.git
Created the Jenkins Job to automate the terraform commands
pipeline {
agent any
environment {
AWS_ACCESS_KEY_ID = credentials('AccesskeyID')
AWS_SECRET_ACCESS_KEY = credentials('Secretaccesskey')
AWS_REGION = "ap-south-1"
}
stages {
stage("Checkout from GIT") {
steps {
git branch: 'main', url: 'https://github.com/Madeep9347/test-project.git'
}
}
stage("Terraform Init") {
steps {
script {
//sh 'terraform init -reconfigure -input=false'
sh 'terraform init -reconfigure'
}
}
}
stage("Terraform Format") {
steps {
script {
sh 'terraform fmt'
}
}
}
stage("Terraform Validate") {
steps {
script {
sh 'terraform validate'
}
}
}
stage("Terraform Plan") {
steps {
script {
sh 'terraform plan'
}
}
}
stage("Terraform Apply") {
steps {
script {
sh 'terraform apply --auto-approve'
//sh 'terraform destroy --auto-approve'
}
}
}
}
}
STEPS:
Postgres Setup:
1.Connect to bastion_host EC2 Instance and add the pem file and change the file
permissions using chmod 400 <pemfile>
2.Using that pem file and connect to the Postgres Instance in the Private subnet and update
the packages
Sudo apt update
3. Install the postgres using “sudo apt-get install postgresql”
4. Set the New Password to the postgres
5. Move to this path /etc/postgresql/16/main and update the pg_hba.conf fle
2. Now Create the Application Load Balancer using the Webapp Target Groups
3. Allow the security ports 80, 443 for webapp ALB
4. Create the Simple record for ALB in route53
5. Generate SSL/TLS certificate for the webapp ALB using aws certificate manager and
certificate as a record in route53
Github Repositories:
Infrasetup: https://github.com/Madeep9347/test-project.git
WebApplication: https://github.com/Madeep9347/test-webapp.git
Domain Names:
https://jenkins.madhumadeep.world/
https://webapp.madhumadeep.world/