Project 1 - DevOps (Implementation)

Project 1 - DevOps (Implementation)

Project 1: Implementation.

?Jenkins CI/CD pipeline with GitHub webhook integration for Deploying Docker application on EC2 instances using the declarative pipeline.

Follow the steps:

1.?????First of all, go to AWS portal, and create a new instance. As,

·???????Name: jenkins-server

·???????AMI: ubuntu.

·???????Instance type: t2.micro (free tier).

·???????Key pair login: Create > docker.pem.

·???????Allow HTTP.

·???????Allow HTTPS.

(Download the .pem file.)

Click on Launch Instance.

No alt text provided for this image


2.?????Now, connect to the EC2 instance that you have created. Copy the SSH from server:

No alt text provided for this image

?

3.?????Go to the download folder, where the .pem file is placed and open the terminal in the same location, and paste the SSH.

?

4.?????In the machine, run the command

“ssh-keygen”

This will generate public and private keys in the machine.

Id_rsa – Private Key.

Id_rsa.pub – Public Key.

No alt text provided for this image


5.?????Now we will install Jenkins on the machine, by following this link ?

https://www.jenkins.io/doc/book/installing/linux/

This will automatically install java with Jenkins.

?

6.?????Install Docker as well to the machine by running,

“Sudo apt-install docker.io”

?

7.?????Now check if it got installed by running “jenkins --version” and “docker --version”

No alt text provided for this image


8.?????Now, we will allow ports 8080 and 8001 for this machine from a security group. We can find the security group in the VM description. Now, here we need to allow “Inbound Rule” as below:

No alt text provided for this image

?

9.?????Now, Copy the Public Ip of the machine and paste it to the browser to access the Jenkins portal. As,

“54.193.49.139:8080”

No alt text provided for this image

?

10.??We need an Administrator Password to unlock this. For that, go to the provided highlighted path in the upper screenshot.

“cat /var/lib/Jenkins/secrets/initialAdminPassword”

No alt text provided for this image

Paste this password in the “Administrator Password” Column.


11.??Now Click on, “Install Suggested Plugins”

No alt text provided for this image

?

12.??This will now install the suggested plugins. As

No alt text provided for this image

??

13.??Now, Jenkins will ask us to create the First Admin User.

No alt text provided for this image

?

14.??Add the fields accordingly.

No alt text provided for this image

?

15.??The Jenkins homepage will look like this,

No alt text provided for this image


16.??Now, we will create a CI/CD pipeline, which will fetch the code from GitHub.?


17.??From Jenkins Dashboard, Click on “New Item”.

No alt text provided for this image

?

18.??Now, Add name as

Name: todo-app

Project: Freestyle project

Click “Ok”.

No alt text provided for this image


19.??Here, we need to fill up the description.

No alt text provided for this image


20.??In Source Code Management, select Git and Add Repository URL and Credentials.

(If there is not any added credential, we need to add)

No alt text provided for this image


21.??In Build Step, select Execute Shell and write following command to build docker image and from Docker image we will create a container.

No alt text provided for this image

?

22.??Now, Click on build Now. And the build will be started, in the build history.

No alt text provided for this image

?

23.??In Output Console,

No alt text provided for this image

?

24.??After getting success, In the browser, search for

<public_ip_of_ec2:8001>

No alt text provided for this image

Now, our goal is,

·???????Whenever the developer commits their code in GitHub, after every commit, it should reflect in the live web app.

·???????For that, we will use “GitScm polling”.

·???????Every time, a developer made a commit, a trigger will run automatically, which will rebuild the image and run a container on your behalf as a part of automation that will run the pipeline automatically.


25.??Now, configure the project again, and add

Build Trigger: GitHub hook trigger for GitScm polling.

Description: GitHub webhook integration

No alt text provided for this image


26.??We need to install the “Git Integration” plugin from Manage Jenkins, by following the path,

(Manage Jenkins > Manage Plugins > Git Integration).

No alt text provided for this image

?

27.??Now, Goto GitHub > Settings > SSH and GPG Keys > New SSH Key.

Add details as

Title: [email protected]

Key type: <public_key>

No alt text provided for this image

?

28.??To get the Public key, open the “id_rsa.pub” file and copy the content. (Public Key)

No alt text provided for this image


29.??Now, we need to go to GitHub and create a new SSH and GPG Key.

GitHub > Repo “react-django-demo-app” > Settings > Webhooks.

30.??Add the following details,

Payload URL: https://<public_ip_of_ec2>:8080/github-webhook/

Content Type: application/json

Which event would you like to trigger this webhook?

o??Just the push event.

Active: True

Click on “Add Webhook”.

No alt text provided for this image

?

31.??Now, Save the configured project.

32.??Do some changes in the code and push to GitHub, this will automatically run a pipeline, and the new code will be Live.

Karim Gouem

AWS Cloud & DevOps Engineer

8 个月

One of the Best DevOps guy I’ve ever met !!!!

Vivienne Dotsey

DevOps Engineer || Cloud Engineer || Solutions Architect || Linux System Administrator || Site Reliability Engineer (SRE) || AWS ||

9 个月

Thank you?

Muhammed Salil

Linux System Administrator

1 年

Thanks

Raviteja Darla

AWS DevOps Engineer || AWS Cloud Services | Jenkins CI/CD | Kubernetes | Docker | Terraform | Ansible | Git | Linux (ubuntu) | Python | SonarQube | Prometheus | Grafana

1 年

Hi Chetan R can you please provide the Source code link github

Kumar Anuraj

SAP MM l Procurement Analyst l Supply chain l MS Excel I Linux

1 年

Great work

回复

要查看或添加评论,请登录

Chetan R的更多文章

  • Interview Question Series - 7 (Monitoring)

    Interview Question Series - 7 (Monitoring)

    Here are the top frequently asked interview questions for Monitoring: 1. What is monitoring in DevOps, and why is it…

    5 条评论
  • Interview Question Series - 6 (AWS)

    Interview Question Series - 6 (AWS)

    1. What is AWS and how is it different from traditional data centers? AWS is a cloud computing platform that offers a…

    3 条评论
  • DevOps Project - 15 (Step-by-step Implementation)

    DevOps Project - 15 (Step-by-step Implementation)

    DevOps Project - 14: Deploy DOTNET web app using Azure PAAS service, use Terraform to deploy infrastructure, and…

    4 条评论
  • Interview Question Series - 5 (CI/CD)

    Interview Question Series - 5 (CI/CD)

    Interview Question Series - 5 (CI/CD) 1. What is CI/CD? >> CI/CD stands for Continuous Integration/Continuous…

    20 条评论
  • DevOps Project - 14 (Step-by-step Implementation)

    DevOps Project - 14 (Step-by-step Implementation)

    DevOps Project - 14: 3 Tier Application Deployment using Kubernetes EKS Cluster. 1.

    36 条评论
  • DevOps Project - 13 (Step-by-step Implementation)

    DevOps Project - 13 (Step-by-step Implementation)

    The very first step is to Install Terraform in your machine, by visiting the official site of Terraform. Here you need…

    14 条评论
  • Interview Question Series - 4 (GIT)

    Interview Question Series - 4 (GIT)

    1. What is Git, and how does it differ from other version control systems? Answer: Git is a distributed version control…

    13 条评论
  • Interview Question Series - 3 (Kubernetes)

    Interview Question Series - 3 (Kubernetes)

    1. What is Kubernetes, and why is it important for container orchestration? Answer: Kubernetes is an open-source…

    10 条评论
  • Interview Question Series - 2 (Docker)

    Interview Question Series - 2 (Docker)

    1. What is Docker? Docker is an open-source platform that allows you to automate the deployment, scaling, and…

    17 条评论
  • DevOps Project - 12 (Step-by-step Implementation)

    DevOps Project - 12 (Step-by-step Implementation)

    Project 10: Build a website using AWS CodeCommit and AWS CodeBuild. Here is the Architecture: 1.

    24 条评论

社区洞察

其他会员也浏览了