Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

DevOps PGR301 Exam 2018 - Continuous Integration (CI) using Concourse and infrastructure using Terraform

Notifications You must be signed in to change notification settings

mudasar187/DevOps_Infra_Exam2018

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DevOps Exam PGR301

Exam Fall 2018

Concourse + Terraform

Technologies

Project include

  • Basic pipeline
  • Docker
  • Surveillance, Alert and Metrics
  • StatusCake
  • Maven cache dependencies
    • When you commit a change to app, it wont download all the dependencies again, the build will go faster.
  • Terraform bug fixed
    • Implemented a fix where Infrastructure will fail the second time it runs. Because git is complaining due to changes to commit. This fixed in terraform apply in terraform.sh file

How to run

You need to create account on these following websites:

Follow all these steps step by step

  1. Fork repositories and download them

  2. Generate RSA keys

    • Open terminal and enter these commands
      • ssh-keygen -t rsa
      • Enter filename for this key -> deploy_key_app and leave other options blank
      • Do the same step again and this filename should be deploy_key_infra and leave other options blank
      • You will noe get 4 files
        • deploy_key_app
        • deploy_key_app.pub
        • deploy_key_infra
        • deploy_key_infra.pub
      • Use the *.pub public keys for Github repos, and for the other files follow steps in item 3 below.
  3. Credentials

    • Open infrastructure repository and find the file credentials_example.yml and rename this file to credentials.yml and add following credentials to this fields:

      • deploy_key_infra replace with your deploy_key_infra file you made
      • deploy_key_app replace with your deploy_key_app file you made
      • heroku_email replace XXX with your email registrated at Heroku
      • heroku_api_key replace XXX with your Heroku api key
      • github_token replace XXX with your Github token
      • heroku_app_name replace "gotrest" with a name you choose
      • statuscake_api_key your StatusCake api key
      • heroku_graphite_ci leave it blank for now
      • heroku_graphite_staging leave it blank for now
      • heroku_graphite_production leave it blank for now
    • Now open the variables.tf file

      • replace "gotrest" with the name you choosed in heroku_app_name in credentials.yml file.
      • replace "gotrest-pipeline" with the name you choosed in app_prefix, eg: yourname-pipeline
    • Now open statuscake.tf file

      • at provider statuscake replace XXX with your email registred at StatusCake without '@' and without dot. This means if your email is e.g: example@mail.com , replace XXX with 'examplemailcom'
    • Now open provider_heroku.tf

      • replace XXX with email registred on Heroku
    • Now open pipeline.yml file

      • replace "XXX" to your forked repo URI´s
  4. Run application

    • When you have made all the changes in the item number 3 above you are ready to run the application. Do these following steps step by step
      • Push the new changes to your Github repo
      • Open terminal and run this command from root
        • docker-compose up or docker-compose up -d for detached mode
      • Open an another terminal and navigate to your infrastructure folder, run these commands and do following
        • fly -t devExam login --concourse-url http://127.0.0.1:8080 -u admin -p admin
        • fly -t devExam sp -c concourse/pipeline.yml -p ci+terraform -l credentials.yml
        • Click on the following url provided in terminal
        • enter username and password, user and password is: admin
        • go back to terminal and run command fly -t devExam unpause-pipeline -p ci+terraform
        • navigate back to browser
        • click on infrastructure job and trigger build, the build job will start automatically
        • when infrastructure job is finished (green box) then heroku-set-config-vars wil automatically start
        • when build is finished (green box) then deploy-ci-app will automatically start
        • infrastructure is build and app is deployed
        • open Heroku and navigate to the pipeline which has been created by infrastructure. You will see following three apps: ci, staging and production
        • now go into each of them and click on Hosted Graphite addon and a new page will pop up. Click on Metrics from your code and copy the url between "nc" and "2003". Copy all url´s from each of ci, staging and production and paste them into credentials.yml file inside infrastructure folder at the bottom of the file. Be careful and add ci to heroku_graphite_ci field. Do same with the other two.
        • When they are added, run this command in terminal again from infrastructure folder fly -t devExam sp -c concourse/pipeline.yml -p ci+terraform -l credentials.yml
        • go back to broswer, click on heroku-set-config-vars and trigger the build
        • After all these steps are done, you can now open the app on Heroku from ci app. It will not show anything because this is a rest api. But you can try all the following url below by adding it after Heroku url as shown below.
HTTP Endpoint Surveillance, Alert and Metrics
GET by charactername /gotrest/api/gameofthrones?characterName={characterName}&limit=1&offset=0 e.g: Arya Stark Counter & Timer
GET by search /gotrest/api/gameofthrones?limit={int}&offset={int}&search={search} Counter & Timer
GET by id /gotrest/api/gameofthrones/{id} Meter
DELETE by id /gotrest/api/gameofthrones/{id} try on Postman Meter
PUT update by id /gotrest/api/gameofthrones/{id} make a get request, use the fields and try PUT method on Postman Meter
POST by id /gotrest/api/gameofthrones make a get request, use the fields and try POST method on Postman Meter
  1. Try make changes on application and make a git push
    • You will now see build job is triggered automatically, it may take a little time, be patience
    • Notice how fast build job is executed because of maven dependencies

skjermbilde 2018-11-25 kl 13 01 18

About

DevOps PGR301 Exam 2018 - Continuous Integration (CI) using Concourse and infrastructure using Terraform

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published