/orange-challenge

Project create to complete a orange challenge.

Primary LanguageJavaScript

Project logo

Cloud Assignment

codename: orange-challenge


codename Status License


This project are created in order to show main devops position skills: pipelines, iac, scripting and cloud.

📝 Table of Contents

🧐 Requirements

The main objective of this project is achive the below requirements:

  • As a DevOps engineer, I want to have a CI/CD pipeline for my application The pipeline must build and test the application code base. The pipeline must build and push a Docker container ready to use. The pipeline must deploy the application across different environments on the target infrastructure.
    • Bonus point: Separate the backend and the frontend in different pipelines and containers.
  • As a DevOps engineer, I want to have a pipeline to deploy the required infrastructure for my application The infrastructure must be created on the cloud, for the purpose of the assignment any public cloud can be used. The deployment pipeline must use infrastructure as code (Cloud Formation, Cloud Deployment Manager, Azure Resource Manager or Terraform). The delivered infrastructure must be monitored and audited. The delivered infrastructure must allow multiple personal accounts. For the purpose of the assignment, you will define the cloud architecture that you see fit, document it and explain the resources created and choices made.
    • Bonus point: The delivered infrastructure must be able to scale automatically.
    • Bonus point: Modify the application to make use of real database running on the cloud, instead of the in-memory database.TIP: We'd highly appreciate if you provide cleanup/destroy functionality as part of the pipeline

⛏️ Solution

The technologies and tools selecteds to achieve the requeriment are:

  • Cloud Provider: Azure
  • CI/CD tool: Git Hub Action
  • Container Registry: Azure container Registry
  • Container : Azure WebApp for containers
  • Monitoring Tool: Azure App Insight
  • Infrastructure as code : Azure ARM templates

The application has been deployed in Azure, the pipeline process is explaining below:

  1. First create the resource group whom will store the resources deployed

  2. After that create a service principal a give the permission only over the resource group created

  3. Deploy the resources with the arm template

    • Azure container Registry
    • Azure WebApp for containers
    • Azure Service plan
    • Azure App Insight
  4. Build a docker image and upload to Azure container registry

  5. Deploy the container image to the webapp

  6. Test access to the web application deployed with a python script and chrome driver (Selenium)

⛓️ Dependencies / Limitations

This version v1 have a below limitations:

  • Static Application's Name beetween different environments
  • Start the deployment infrastructure require execute command in azure CLI
  • The unit-test enviroment is setted just in a Linux environment
  • ⛏️ It's necessary cleanup the insfrastructure before deploy in different environment (Azure Subscription)

🚀 Future Scope

Next version must have:

  • Autoscaling the web app
  • Use SQL Azure Database
  • Separate the backend and the frontend in different pipelines and containers

🏁 How to use

These instructions will get you a copy of the project up and running on your own environment for development and testing purposes.

Fork the project

  1. On GitHub, navigate to the alefred/orange-challenge repository.
  2. In the top-right corner of the page, click Fork. picture alt

Prepare connection with Azure

  1. Connect to az cli with:
az login --use-device-code
  1. Execute next command in your az cli in order to copy the output:
az provider register --namespace 'Microsoft.Web'
az provider register --namespace 'Microsoft.ContainerRegistry'
az provider register --namespace 'Microsoft.insights'
$appSpName="frenchOrange-spApp"
$rgName="frenchOrange_rg"
$subscriptionId = az account show --query id --output tsv
az group create --resource-group $rgName --location "East US 2"
az ad sp create-for-rbac --name $appSpName --role contributor --scopes "/subscriptions/$subscriptionId/resourceGroups/$rgName" --sdk-auth

  1. The output could be similar to:
{
  "clientId": "-------------------------e8",
  "clientSecret": "Y93m-------------------------W",
  "subscriptionId": "f3c-------------------------8",
  "tenantId": "0c6-------------------------",
  "activeDirectoryEndpointUrl": "https://login.microsoftonline.com",
  "resourceManagerEndpointUrl": "https://management.azure.com/",
  "activeDirectoryGraphResourceId": "https://graph.windows.net/",
  "sqlManagementEndpointUrl": "https://management.core.windows.net:8443/",
  "galleryEndpointUrl": "https://gallery.azure.com/",
  "managementEndpointUrl": "https://management.core.windows.net/"
}

  1. Copy the output and paste as a new secret "AZURE_CREDENTIALS" in github repo forked as the image show: picture alt

CI/CD

  1. On GitHub, navigate to the orange-challenge own repository.

  2. Go to Actions Tab and enable Actions "I understand my workflows, go ahead and enable them" picture alt

  3. Push any change to the main branch

  4. Return to Actions Tab

  5. Clic in the name of your last commit pushed picture alt

  6. Browse the app: frenchOrange.azurewebsites.net

Clean Up Infrastructure

n-1. Execute the next list of commands in Azure Cli

$appSpName="frenchOrange-spApp"
$rgName="frenchOrange_rg"
$subscriptionId = az account show --query id --output tsv
az group delete --resource-group $rgName --yes
az ad sp delete --id (az ad sp list --display-name $appSpName --query "[].appId" --output tsv)

🎉 Deliverables

n. Url app after deploy: frenchOrange.azurewebsites.net