This is a python flask based machining learning application that demostrates DevOps based practices. For this project, a spreadsheet and a trello board have been used to define the project plan and track progress respectively. The project also implements Continuous Integration via Github Actions while Continuous Delivery is achieved using Azure DevOps Pipelines. Finally, the project is fully documented with instuctions on how to run the application in the README file.
Follow the steps below to get started and run the project:
-
Connect to Azure Cloud Shell from Azure Portal.
-
Clone the project in Azure Cloud Shell using this command as illustrated below:
git clone git@github.com:chegeapollo11/apollo-udacity-ci-cd-pipeline.git
-
Navigate to the newly cloned project using this command:
cd apollo-udacity-ci-cd-pipeline
-
Create a local working branch from Azure Cloud Shell using this command:
git checkout -b feature/project-demo
-
Publish the local working branch to Github using this command:
git push -u origin feature/project-demo
-
Next, create a python virtual environment from Azure Cloud Shell using this command:
python -m venv venv
-
Activate the python virtual environment using this command:
source venv/bin/activate
-
Make required changes to the project then run tests locally using the following command:
make all
-
Observe the following output from Azure Cloud Shell if the command runs successfully:
-
Execute a simple test run from Azure Cloud Shell by running this command:
python -m pytest -vv --disable-warnings tests/test_app.py
-
Observe the following output from Azure Cloud Shell if the command runs successfully:
-
Commit and push your changes to Github using the following command:
git add . && git commit -m "Test continuous integration" && git push
-
Observe that the Github Actions CI Job is triggered and executes successfully as illustrated below:
-
From Github, create a pull request for your working branch with the master branch as the target branch.
-
Merge and complete the pull request to automatically trigger the Azure DevOps CD Job.
-
Nagivate to https://dev.azure.com/{organization}/{project} and confirm a successful run of the Azure DevOps CD Job from the pipeline execution logs as illustrated below:
-
Navigate to Azure Portal and confirm from the Azure App Service Deployment Center that the application was deployed successfully as illustrated below:
-
Navigate to the App Url and confirm that the application is up and running after deployment as illustrated below:
-
From Azure Cloud Shell, grant execute permissions to the prediction script by running the following command:
chmod +x make_predict_azure_app.sh
-
From Azure Cloud Shell, verify a prediction from the deployed application in azure by running the following command:
./make_predict_azure_app.sh
-
Observe the following output from a successful prediction as illustrated below:
-
From your local cloned repository, run the following command to start a load test using locust:
locust --host=https://apollo-udacity-ci-cd-pipeline-webapp.azurewebsites.net
-
Open your web browser and navigate to the following address to lauch the Locust Web UI:
http://localhost:8089/
-
Enter your preferred number of users and spawn rate as illustrated below then click "Start Swarming" button:
-
Observe the following statistics and charts in the subsequent page:
-
Finally, click the "Stop" button from Locust Web UI and observe the following out from the console logs:
This project implements DevOps best practices on Azure and so far is a great start but can do with the following improvements:
- Add unit tests for the scale and predict methods and ensure the tests run during continuous integration via Github Actions.
- Use a single platform for source code management, continuous integration and continuous delivery i.e. either Github Actions or Azure DevOps Pipelines to simplify maintenance.
- Enable health checks in Azure App Service that minitor the health of the application.
- Add monitoring in Azure on the availability of the application and configure alerts that send email notifications when the application is unavailable.
- Add a front end application with that a user interface that users can interact with to make predictions instead of doing it from the terminal.