GithubHelp home page GithubHelp logo

ooeid / building-a-cicd-pipeline2 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bobfoster1299/building-a-cicd-pipeline2

0.0 1.0 0.0 1.24 MB

'Building a CI/CD pipeline' project for the 'DevOps Engineer for Microsoft Azure' nanodegree program from Udacity

Makefile 6.48% Python 66.44% Shell 27.08%

building-a-cicd-pipeline2's Introduction

Python application test with Github Actions

By Rob Foster

Updated 08/11/2020

Introduction

This is my submission for the 'Building a CI/CD Pipeline' project as part of the 'DevOps Engineer for Microsoft Azure' nanodegree program from Udacity.

This project contains a python application that is designed to predict housing prices in Boston (I did not create the python app myself). This repo will enable you to:

  • Deploy the app in Azure CloudShell
  • Deploy the app as an Azure App Service

Any commits to the GitHub repo trigger automated code testing using GitHub Actions. A pipeline has been created in Azure DevOps, and the updated code is also automatically tested in Azure DevOps and deployed to the Azure App Service.

Here is an architectural diagram: architectural-diagram.png

A Trello board has been created to keep track of tasks to be completed.

A spreadsheet has been created to manage the project schedule.

See here for a YouTube video demonstrating the project.

Instructions

Deploy the app in Azure Cloud Shell

In Azure Cloud Shell, clone the repo:

git clone [email protected]:bobfoster1299/building-a-cicd-pipeline2.git

screenshot-git_clone.png

Change into the new directory:

cd building-a-cicd-pipeline2

Create a virtual environment:

make setup

Activate the virtual environment:

source ~/.udacity-devops/bin/activate

Install dependencies in the virtual environment and run tests:

make all

screenshot-make_all.png

Start the application in the local environment:

python app.py

Open a separate Cloud Shell and test that the app is working:

./make_prediction.sh

The output should match the below:

screenshot-make_prediction.png

Deploy the app to an Azure App Service

Create an App Service in Azure. In this example the App Service is called rob-udacity-webapp and the resource group is called rob-udacity-project:

az webapp up -n rob-udacity-webapp -g rob-udacity-project

Next, create the pipeline in Azure DevOps. More information on this process can be found here. The basic steps to set up the pipeline are:

  • Go to https://dev.azure.com and sign in.
  • Create a new private project.
  • Under Project Settings create a new service connection to Azure Resource Manager, scoped to your subscription and resource group.
  • Create a new pipeline linked to your GitHub repo.

Screenshot of the App Service in Azure:

screenshot-app_service.png

Screenshot of a successful run of the project in Azure Pipelines:

screenshot-azure_pipeline_success.png

To test the app running in Azure App Service, edit line 28 of the make_predict_azure_app.sh script with the DNS name of your app. Then run the script:

./make_predict_azure_app.sh 

If it's working you should see the following output:

screenshot-make_predict_azure_app.png

You can also visit the URL of the App Service via the browser and you should see the following page:

screenshot-browser.png

View the app logs:

az webapp log tail -g rob-udacity-project --name rob-udacity-webapp

screenshot-logs.png

Load testing

We can use locust to do a load test against our application. In this example we will do a load test against the app running locally rather than in Azure.

Install locust:

pip install locust

Ensure the app is running:

python app.py

Start locust:

locust

Open a browser and go to http://localhost:8089. Enter the total number of users to simulate, spawn rate, set the host to localhost:5000, and click Start Swarming:

screenshot-locust_main1.png

You can then watch the load test:

screenshot-locust.png

Future improvements

Currently, there is only a single branch in GitHub. In the future it would be good to create multiple branches, so code can initially be tested and deployed in a staging environment. If it works correctly in the staging environment the changes could then be merged into the production branch and the code deployed into the production environment.

building-a-cicd-pipeline2's People

Contributors

bobfoster1299 avatar robef3 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.