The DevOps Pipeline (lab 7)- Week 1 Final Project
Introduction
In this hands-on lab, you will create a DevOps
pipeline all the way from making a code change to deploying that change to a
production environment. One of the great benefits of DevOps comes from its
focus on automated pipelines, and here you will have the opportunity to try one
out so you can see it in action from a hands-on perspective. After completing
this hands-on lab, you should have a basic idea of what it is like to use a
DevOps pipeline to change the code and get those changes into production. You'll
first need to have a GitHub account and you'll fork the provided repo to your
own GitHub account. This way, we have our own version of the files we can make
changes to.
1.
Fork
the GitHub repo.
Uncheck the box
next to Copy the master branch only
Note: If you
forget to uncheck the box, not all of the forks will copy over to your new repo
and you won't be able to complete the lab.
2. After forking, click on branch, and you
would see 4 branches listed.
Execute the Initial
Deployment
Set Up a Continuous
Integration Server
Copy the Public IP address of the CI server provided
in the lab credentials, and paste it into a new browser tab with :8080 appended
to the end.
We'll land at a Jenkins installation. Click the listed
devops-essentials-sample.
In the left-hand menu, click Configure.
Click the Branch Sources tab.
Navigate to the forked repo that you created in GitHub
and copy the URL to your clipboard.
Navigate to Jenkins, and change the Project Repository
to the copied URL of the fork you created in GitHub.
Note: Notice the username changes, but the URL address
is the same.
Create a Pull
Request
Navigate to the lab credentials section, copy the
Public IP address of production webserver, and paste it into a new browser tab.
Note: You should see the following message: DevOps is
great!
Navigate back to GitHub and click 4 branches.
Locate the new-feature branch, and click New pull
request.
Set the base repository dropdown to your personal
fork.
Set the base dropdown to the master branch.
Make sure the compare dropdown is set to new-feature.
If you scroll down, you will see the changes are
displayed in a code comparison. Once ready, select Create pull request.
Select Merge pull request, and then Confirm merge.
Navigate to the Jenkins server tab, at the top of the
page click the Jenkins breadcrumb link to get back to the main Jenkins page.
Click devops-essentials-sample to view the branches.
Click master.
In the left-hand menu, select Build Now.
When your build gets to the DeployToProd stage, it
will pause and wait for our input to complete. Before we continue, we first
want to check out how the web app looks in the staging environment.
Navigate to the lab credentials section, copy the
Public IP address of staging webserver, and paste it into a new browser tab.
Note: If the
changes have been properly deployed to the staging server, you should see the
following message: DevOps is awesome!
Now that we've confirmed our app change looks ok in
the staging environment, we can push it to production.
Back in the Jenkins > devops-essentials-sample >
master page, hover over the DeployToProd section for a pop-up window to appear
with the following message: Does the staging environment look OK?
Select Proceed.
Return to your browser and navigate to the production
webserver tab with the original message:DevOps is great!
Refresh the page to see the updated text: DevOps is awesome!
Click Save.
Note: Jenkins will automatically start scanning and
building the branches from the fork.
Run the
"Broken" Deployment
Navigate back to GitHub and click 4 branches.
Note: On top of the page, click the root of the forked
project: devops-essentials-sample-app to get back to the main page.
Locate the broken-feature branch, and click New pull
request.
Set the base repository dropdown to your personal
fork.
Set the base dropdown to the master branch.
Make sure the compare dropdown is set to
broken-feature.
Note: Scroll down the page, and notice the spelling
error.
Click Create pull request.
Click Merge pull request.
Click Confirm merge.
Navigate back in the Jenkins tab, and in the left-hand
menu, select Build Now.
Once it gets to the DeployToProd stage, hover over the
DeployToProd section for a pop-up window to appear with the following message:
Does the staging environment look OK?
Select Proceed.
Navigate to the production webserver tab and refresh
the page to see the spelling error.
Roll Back the
Broken Deployment
Navigate back to the Jenkins page, and in the
left-hand menu, click on build #2.
Click Replay.
Click Run.
While that is building, navigate to the staging
webserver tab, and refresh the page to view the correct text.
Navigate to back to Jenkins, hover over the
DeployToProd section, and select Proceed.
Once the update is complete, navigate to the
production webserver tab to view the correct text again, meaning we have
performed a successful rollback.
No comments:
Post a Comment