/Final_project

Last project deployment of a full app

Primary LanguageHCL

Final_project

Last project deployment of a full app spring pet clinic app using an angular front end and a rest back end.

Contents

Run instructions

Project

  • Plan, design and implement a solution for automating the deployments and development workflows.
  • Have multiple enviroment support.
  • Have automatic deployments based on triggers from changes to the github repositry.
  • Have a costing of the solution implmented.

Introduction

User stories

We created our user stories to get an idea of how we wanted to deploy the app. These stories where stored on the project board.

From the user stories we created isues that could then be put into sprint boards that where housed inside the reposotry as projects.

MoSCoW priority

To give clarity on what tasks needed to be run first we prioritise. This was done using custom labels for the github issues wich allowed us to search by urgency.

Service Infrastructure

Our current service infrastructure looks like this. alt text

This implemtation has the testing done on the vm with jenkins on it using docker. The main deployment is then done using a managed kuberneties service on azure.

All of the infrastructure can be spun up using terrafrom scripts that use an azure subcription. The scripts are designed in such a way that they pull the terraform workspace to use as the the name of the resources being deployed. This allows for identical infrastructure to be spun up for developers to test new features on more exstensivly if the automated test arn't surficent.

Kubernetes terraform use

To run the Kubernetes terraform files you will need to have a service principle set up and have the client id and client secret on hand. If not these can be configured using the azure cli with
az ad sp create-for-rbac --role="Contributor" --scopes="/subscriptions/your_subscription_id" To link it to kubectl you will need to run
echo "$(terraform output kube_config)" > ~/.kube/azurek8s And
export KUBECONFIG=~/.kube/azurek8s

Previous versions

Exspand to see the previous iterations of the infrastucture design

Mark 1

alt text

The first idea had a completly seprate testng enviroment with on vm to run the app on using docker and then a second vm running nginx to proxy pass to the dcker vm. The Jenkins vm is only used for Jenkins and has access to the testing and production enviroments. The deployment is done though a managed kubernetues cluster with a nginx load ballencer service.

Mark 2

alt text

The second design varied only slightly from the first the only difrence was that the database was going to use a managed databse service to allow for the data to be more sercure and able to scale better.

CI pipeline

In the CI pipeline we have used git for our source controll, the infrastructure is built using terraform and then configured using ansible. Jenkings was chosen as to manage our continous intergration and the production deployment is done on Azure using Kubernetties. alt text

Risk assessment

alt text

Testing

Front end

The front end tests are run through a browser using one of the testing images of the front end the current testing image is labled T1. To access the tests you will need to navigate to ip of the machine that the test are run on port 9876 and then on the webpage it will have a button that says debug. When that button is pressed it tests all of the routing for the front end.

alt text

Back end

To test the back end the reposity that contains the code and then run the mvn test command. If you want to test that the docker image that you are running then you need to exec into the container and run /mvnw test. These commands run the same tests that cover the entire backend.

alt text

End to end

The end to end tests are run from the front end immage agian and spin up a virtual testing enviroment to test them. This is done using the fronend image T2 which automaticly starts the tests on start up. Unfourtantly the virtual browser that it is tryng to spin up is currently breaking on start up so the tests arn't running correctly. We have tried pointing the tests to other supported browsers but unfourtantly they are not being pulled down correctly so these tests are currently not in a functional state.

Cost analysis

With our current infrastructure the cost isn't fixed for a mont because the Kubernetties cluster has auto scaling up to 3 nodes by default but if demand was high this could be exspanded. This does give us a band under normal operation that this deployment would cost.

The vm sizes for the project are as follows.
Jenkins VM: DS1 V2 (1vCPU core 3.5GB RAM)
Kubernities nodes: DS1 V2 (1vCPU core 3.5GB RAM)

The minium cost per month with this set up is £95.58 this assumes that the Kubernetties cluster only ever has one vm in the node. The maximum monthly cost would be £191.12 but this requires the node to be scaled up to the maximum number of VMs all of the time wich would be unlikley to happen and if it was happening you would need to look at provisioning more infrastructure in anycase. The full breakdown of the costs can be found here.

Conclusion