Git Product home page Git Product logo

devops-challenge's Introduction

DevOps-Challenge

This challenge is divided into two parts:

Part-1: Programming

Create a simple REST API using your preferred programming language that does the following:

  • It responds to the URL like http://host-ip/ and returns: Hello World, I'm Omar
  • responds to the URL like http://host-ip/?n=x and returns n*n
  • It responds to the URL like http://host-ip/ip with the IP address of the client making the request and save that IP address on Postgres
  • It responds to the URL like http://host-ip/allips with all of the saved IP addresses after retrieving it from Postgres.
  • The app is served via a wsgi handler. Like uWSGI
  • The Application is Dockerized.

Part-2: Deployment

there are several options to deploy the app

in this option we will use sqlite database

  1. Install Docker
  2. Clone this repo
git clone https://github.com/omarelsheekh/DevOps-Challenge
  1. Build the docker image
docker build -t <image name> DevOps-Challenge/app/
  1. Run the docker image
docker run -e "db_type=sqlite" -dp 5000:5000 -p 9191:9191 <image name>
  1. Install Docker on all machines
  2. Install kubectl on machines you will run commands from
  3. Setup a K8s cluster, you can pick one of these options
  4. Install helm on machines have kubectl installed
    curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
  5. Clone this repo
    git clone https://github.com/omarelsheekh/DevOps-Challenge
  6. Build the docker image
    docker build -t <image name> DevOps-Challenge/app/
  7. move to helm-chart directory
    cd DevOps-Challenge/helm-chart
  8. Run the app helm chart
    helm install --set app.image=<image name> app .
    • warning: if you running it on minikube you have to set affinity to ""
      helm install --set app.affinity="" --set postgresql.affinity=""  --set app.image=<image name> myapp .
  9. Verify the IP addresses is set to the ingress:
    $ kubectl get ingress
    NAME                CLASS    HOSTS   ADDRESS        PORTS   AGE
    myapp-app-ingress   <none>   *       192.168.49.2   80      9m13s
  1. Verify that the Ingress controller is directing traffic
    $ curl 192.168.49.2/
    Hello World, I\'m Omar

Using the automation tool (Terraform) prepare a FULLY provisioned environment.

This automation should:

  • Provision 3 nodes on Azure, On these 3 nodes deploy:
    1. The API
    2. DB Master (PostgreSQL)
    3. DB Slave (PostgreSQL) and Setup master-slave (streaming replication) PostgreSQL between node 2 and 3.
  • Deploying the Dockerized API on the App node

Getting Started

  1. Install Terraform
  2. Install azure Cli
  3. log in to your azure account
    az login
  4. Make Sure that your subscription is active
    $ az account list
    
    [
      {
        "cloudName": "AzureCloud",
        "homeTenantId": "f6****22-84be-48a6-b**c-c0*******1f1",
        "id": "b7*****1-475c-41a6-a**2-d********f1c",
        "isDefault": true,
        "managedByTenants": [],
        "name": "Azure for Students",
        "state": "Enabled",
        "tenantId": "f6****22-84be-48a6-b**c-c0*******1f1",
        "user": {
          "name": "[email protected]",
          "type": "user"
        }
      }
    ]
  5. Install Ansible
  6. Clone this repo
    git clone https://github.com/omarelsheekh/DevOps-Challenge
  7. Change your directory to the repo
    cd DevOps-Challenge
  8. Change default variables in variables.tf if you want

Start Building All Infra in One Command

./create-infra.sh

Destroy Infra Whenever you want

./destroy-infra.sh

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.