MLops task-1: Integration of Jenkins, Docker and Git&GitHub(using master and feature branch)

No alt text provided for this image

Jenkins workflow:

No alt text provided for this image

Task Description:

JOB#1

If Developer push to dev branch then Jenkins will fetch from dev and deploy on dev-docker environment.

JOB#2

If Developer push to master branch then Jenkins will fetch from master and deploy on master-docke environment. Both dev-docker and master-docker environment are on different docker containers.

JOB#3

Manually the QA team will check (test) for the website running in dev-docker environment. If it is running fine then Jenkins will merge the dev branch to master branch and trigger job2.

Before performing the task, there are some pre-requisites:

a] Redhat (RHEL 8 in my case) or any linux OS

b] Account on GitHub

c] Already configured Jenkins Setup

d] Git Bash software on windows or linux

STEP 1:

First create a local repository in Git as well as a repository in GitHub. But if you are using Git for first time then we have to tell Git our GitHub username and email ID by using the following commands.

commands:

git config --global user.email "[email protected]"

git config --global user.name "your_name"

We have to initialize the local repository using git init command. Also, To add a new remote, use the git remote add command on the terminal, in the directory your repository is stored at (here origin is our remote name).

No alt text provided for this image

remote origin : Adding remote SCM url to which you want to push the local repository.

STEP 2:

By default both Git and GitHub will give you a master branch. So, first in master branch I created a file named mypage.html and wrote some code in it.

No alt text provided for this image

After this I used series of commands and pushed this file to GitHub into master branch.

No alt text provided for this image

STEP 3:

Now, I created a feature branch named dev1 using the following command:

No alt text provided for this image

By this command, branch is also created and we are also switched to that branch.

No alt text provided for this image

In dev1 branch, I updated my code of mypage.html by adding <style> attribute to add background color.

No alt text provided for this image

Here also I used series of commands and pushed this file to GitHub into dev1 branch this time.

No alt text provided for this image

STEP 4:

Here after doing the above step, I have also created a hook. Git hooks are scripts that run automatically every time a particular event occurs in a Git repository. They let you customize Git's internal behavior and trigger customizable actions at key points in the development life cycle.

I have created a post-commit hook, meaning after every commit automatically it will push to GitHub.

No alt text provided for this image
No alt text provided for this image

Let's create the jobs in Jenkins.

JOB 1:

This job will check the dev1 branch in the GitHub and copy the code from Jenkins to developer folder in root directory of base OS i.e RHEL 8 also launch a docker image (OS) which is the testing environment if it is not there and if it is there then it will remove that and create a new image (good practice in testing) and is not exposed to the clients. The contents of developer folder will be mounted to a particular folder.

It will check the changes in dev1 branch and will trigger JOB 3 once the testing is successful.

Here I have done Poll SCM, meaning Jenkins will keep on checking GitHub for any new code every minute. We can do remote trigger also, by using the authentication token.

No alt text provided for this image
No alt text provided for this image

Console output for JOB 1:

No alt text provided for this image

JOB 2:

In this job, Jenkins will pull/copy code from master branch. This job will check the master branch in the GitHub and copy the code from Jenkins to master folder in root directory of base OS i.e RHEL 8 also launch a docker image (OS) which is the production environment. If it is not there it will launch a new image/container and if it is there then it will print "Already Running" in console output. This container/environment is exposed to clients as well.

No alt text provided for this image
No alt text provided for this image

Console output for JOB 2:

No alt text provided for this image

JOB 3:

It will merge the two branches only if the dev1 branch is completely tested and as soon as this job is done, master gets changed and JOB 2 is triggered to deploy changes into the production environment.

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

Console output for JOB 3:

No alt text provided for this image

FINAL OUTPUT:

No alt text provided for this image

GitHub link:



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

Richard Nadar的更多文章

  • MITRE ATT&CK

    MITRE ATT&CK

    Introduction MITRE ATT&CK stands for MITRE Adversarial Tactics, Techniques, and Common Knowledge. The MITRE ATT&CK…

  • ARTH TASK-6 & AWS-CSA TASK-2

    ARTH TASK-6 & AWS-CSA TASK-2

    CloudFront: Amazon CloudFront is a fast content delivery network (CDN) service that securely delivers data, videos…

  • Machine Learning Case Study on Harley Davidson

    Machine Learning Case Study on Harley Davidson

    Machine Learning: “Machine Learning is the science of getting computers to learn and act like humans do, and improve…

  • GCP TASK

    GCP TASK

    Google Cloud Platform: Google Cloud Platform (GCP), offered by Google, is a suite of cloud computing services that runs…

  • Case Study of Ubisoft Gaming Company paired with AWS

    Case Study of Ubisoft Gaming Company paired with AWS

    Amazon Web Services (AWS): AWS (Amazon Web Services) is a comprehensive, evolving cloud computing platform provided by…

  • BIG DATA: A Umbrella of Challenges

    BIG DATA: A Umbrella of Challenges

    Introduction: In today’s world data is everything, without data nothing is possible. But the thing is that the data is…

  • MLops-task2: Complete Automation using Jenkins, Docker, Git&GitHub Integration

    MLops-task2: Complete Automation using Jenkins, Docker, Git&GitHub Integration

    Jenkins: Jenkins is an open source automation server. With Jenkins, organizations can accelerate the software…

  • Complete application built on AWS-EKS architecture

    Complete application built on AWS-EKS architecture

    AWS-EKS: Amazon EKS (Elastic Container Service for Kubernetes) is a managed Kubernetes service that allows you to run…

  • Mlops task-3 : ML and Devops integration using Jenkins

    Mlops task-3 : ML and Devops integration using Jenkins

    Task description is as follows: 1. Create container image that’s has Python3 and Keras or numpy installed using…

  • Hybrid Multi Cloud Task-1

    Hybrid Multi Cloud Task-1

    Task description: 1. Create the key and security group which allow the port 80.

社区洞察

其他会员也浏览了