Basic Example to explain the Workflow of DevOps using webserver
Kritik Sachdeva
Technical Support Professional at IBM | RHCA-XII | Openshift | Ceph |Satellite| 3Scale | Gluster | Ansible | Red Hatter
In companies, three different teams are working in parallel to push the application into the production world, so that their clients can make use of it.
These 3 teams include Developers, Testing, and Operation team. And due to the difference in their working environment and tools they use to work on creates a wall in between them. That wall is called Silos.
To overcome these silos, a kind of culture is being made typically called the DevOps, where these 3 teams work combined without any hurdle continuously. That provides agility and faster development of the application to their client
Deploying the website on the apache docker container creating a pipeline through Jenkins
Process for this example would be:
- Create a git repository and develop a Jenkins job that will fetch from the dev branch on every update
- On every update launch a live httpd container for the testing environment
- Jenkins will test the website running in the test environment. If it passes the test, dev branch will be merged to the master branch, and application/website is being deployed in a separate production environment
To accomplish this example, the process I have followed is creating two different pipelines. As one for launching container/application into the testing environment and another for testing and finally deploying into the production environment
Phase-1:
This phase includes two jobs as a) Pulling the code from the Github b) Launching the application in the testing environment.
Job-1
This job is responsible for pulling the code from the dev branch plus performing copying files into a different location so that this space gets cleaned after use.
Build Section:
rm -rf /task-1/ cp -rvf * /task-1/
Job-2:
For this job, the hierarchy of the code on Github should include Dockerfile and other source code files at the same location as,
Using this approach we can create the docker image for our application live from scratch.
This job would be Downstream for the previous job of pulling the code from Github.
In the building part, whenever the code is updated in the Github, a new docker image is being created and used for deploying the application.
Phase-2
This phase includes 3 jobs as, a) testing the code or the application deployed in the testing environment by running some test b) Merging the code into the master branch c) Deploying the application into the production environment
Job-1
This job includes some tests that are usually done by the testing either through running some test scripts or other means. In this post, I have just used the status of the web page as it would be accessible.
Job-2
In this Job, we will merge the dev branch to the master branch so that it could be finally deployed in the production environment.
First, we enter the Github repository URL as we do for pulling the code along with the credentials which are required to merge the code back to the master branch.
Then, for merging we use the post-build actions
Job-3
This job is similar to job-2 in the phase-1, as where we deployed the application in the testing environment. Here we will deploy it on the production environment.
For reference to the Github code: Github Link
If you have any doubts, then drop me a message. I will definitely try to revert you back.
Thank you.