DEV Community

Cover image for Let's build a DevOps project :
Rahul Kumar
Rahul Kumar

Posted on • Updated on

Let's build a DevOps project :

The Agenda :

This is a project in which we have to take an application through DevOps lifecycle .

  1. Integrating the source code in a version control environment for mutual development.
  2. The application must pass through a ci/cd pipeline .
  3. continuous monitoring is enabled for fault tolerance .

Phases in DevOps :

  • Planning
  • Coding
  • Testing
  • Building
  • Release
  • Deploy
  • Operate
  • Monitor

Planning :

A better planning of an application can lead to a better growth of our application where we have to design our system where high level system design is involved like flow charts, features , intended users , security , Relationship in the database .

Coding :

Then we have to do the coding according to the features . where low level design is involved .
Alt Text

Testing :

A simple unit testing is good enough for our application if we are not building a high scale application . Since we are using DevOps so we using Selenium to automate application testing . we use the selenium web driver and TestNG for report writing and Maven for managing our dependency .

Building :

  • In the building stage we are going to implement packaging , error testing, basically integrate our application with Jenkins which is a ci/cd pipeline tool which can trigger our code by configuring with webhook and then automating the testing using selenium .

  • So there are mainly two types of servers one is for testing and another is production .

  • So our application first should go to the testing servers and then to the production servers .

Alt Text

Release :

In the release state we are releasing a MVP of our application to our intendent uses .
Alt Text

Configuration management :

This is a phase of infrastructure as a service where we have to write code for our infrastructure . and to automate it because we are using DevOps and this can be achieved by Configuration management tools such as ansible, puppet, Ceph , SaltStack . Let's suppose our application needed more resources so that we have to allocation new servers and manually we could do that but if we think in a large scale so it is a repeatative task so by using configuration management tools we could make sure that automated servers added to our infrastructure when ever needed .
Configuration management

Monitor :

  • Monitoring our application is really a essence like monitoring our infrastructure . Monitoring based upon different metrices
    like resource utilization (Mainly CPU and Memory) .

  • When it find potential failure symptoms an Alert has been triggered with the log about which part of our application crashes .


Steps :

  • We are use two machines one is the worker and another one is the slave machine .

  • create two ec2 instances in AWS and connect using SSH .
    Alt Text

  • Install Git and Jenkins(Java as a prerequisite) on the master Node .

  • Fire up Jenkins web dashboard in the usual steps .


  • configure setting where we have to create a new node and then configure our node machine by downloading two files and if we are downloading them we have to use the SCP command to copy them to the master node .

$scp -i /downloads/.pem (name of the files) ubuntu@ip:/home/jenkins

  • Configure webhooks for a triggering point whenever we are pushing our code into GitHub .

  • Coming to the node machine we need to install Java and git .

  • clone the git repos modify some change .

  • add it to the staging area (place where git can track all the files ) .

$git add .

$sudo git commit -m "Initial commit"

Then copy the ip address of Jenkins go to the settings of your repository add a webhook .

  • recognized as a payload URL


Implement a Job inside Jenkins
create a new item test-job

  • Create a docker file


The container is consists of the operating system and the required software .
It our case in this container Ubuntu is the OS and apache is configured as a webserver .

FROM hshar/webapp
ADD . /var/www/html
Enter fullscreen mode Exit fullscreen mode

In the Jenkins build environment

sudo docker rm -f $(sudo docker ps -a -q)
sudo docker build /home/ubuntu/website/. -t test
sudo docker run -it -p 82:80 -d test
Enter fullscreen mode Exit fullscreen mode

Now we have to test our application :


  • Install selenium webdriver , the singleton server and the chromedriver as per your operating system .

Install in on test-server

$sudo apt install chromium-browser

Go to this link !



Lets write a simple
/home/ubuntu/chromedriver as a path
execute it on headless mode because our ubuntu server does not have a dashboard .

public class Test {

   public static void main(String []args) {

       System.setProperty("", "C:\\Selinium\\chromedriver.exe");

       ChromeOptions options = new ChromeOptions();

       WebDriver driver = new ChromeDriver(options);

       driver.get("http://(ip address)/");

Enter fullscreen mode Exit fullscreen mode

java -jar hello.jar

Then transfer it to the node machine scp

Lunch a production server instance

$sudo apt install open-jdk

$sudo apt install docker

Go to jenkins
add a new node called prod server and the location is /home/ubuntu/jenkins
run the jnlp file

next create a new job as a prod branch without webhook

echo hello
sudo docker rm -f $(sudo docker -ps -q)
sudo docker build /home/ubuntu/jenkins/workspace/test-job/. -t prod
sudo docker run -it -p 80:80 -d prod 
Enter fullscreen mode Exit fullscreen mode
cd jenkins 
cd workspace 
cd test-job
Enter fullscreen mode Exit fullscreen mode
  • create a new job called test-job
  • same github url
  • label expression test-server
sudo cp ./hello.jar /home/ubuntu
sudo java -jar /home/ubuntu/hello.jar
Enter fullscreen mode Exit fullscreen mode
  • test-github-webhook
  • post-build-action build-website
  • save

  • build-website

  • remove build triggers

  • add test-website post-build

  • test-website

  • build-other-project -- test-job

  • add a new pipeline view
    define the initial job other will be handeled by post-build action

  • Inside the test-server

sudo mv ./hello.jar /home/ubuntu/website
cd website
git add . 
git commit -m "test jar added"
sudo git push -u origin master 
Enter fullscreen mode Exit fullscreen mode
  • Lets go to master server for configuration management
    cd jenkins/workspace/test-job

  • The ip address of production server paste in on browser .

  • Modify it on test server

cd website
change something
commit -m "Final commit"
sudo push -u origin master 
Enter fullscreen mode Exit fullscreen mode

New job named as Develop-branch
restrict it to the test-server

sudo docker rm -f $(sudo docker ps -t -q)
sudo docker build /home/ubuntu/. -t test1
sudo docker run -it -p 85:80 -d test1
Enter fullscreen mode Exit fullscreen mode

Configuration management using ansible:

  • In this phase we have to install a Configuration management which is ansible in our case . which helps achieve infrastructure as a code basically writing code for our infrastructure .

Continuous monitoring using Nagios :

  • The Final step in our loop and most important phase .

Thank You for reading πŸ€–πŸ€–πŸ€–

Top comments (1)

gorynych profile image
Info Comment hidden by post author - thread only accessible via permalink
Stepan Mozyra

Author is out of whack with himself. Installation by hands? Copying something? Creating files? C'mon )) Are you sure this is about devops? )))

Some comments have been hidden by the post's author - find out more