-
Git Clone
- Fork both repositories linked above.
- Download the two forked repositories to your computer.
-
RSA Keys
- Now you need to create RSA keys for both git repos.
Open a terminal window and run this command to generate RSA keys:
ssh-keygen
. You will be promted to write a filename, write the following:deploy-key-app
, leave the other fields blank. - Run the same command as in the previous step but with a different filename:
deploy-key-infra
. - Now use public keys as deployment keys online in the github repos.
- Now you need to create RSA keys for both git repos.
Open a terminal window and run this command to generate RSA keys:
-
Credentials
-
Now Open the Infrastructure repository that you have downloaded. In the project root directory rename the
credentials_example.yml
tocredentials.yml
. -
In the `credentials.yml file, replace all the credentials to your own, except for: logz_io_token.
- Replace the word
pokemon
with a name you choose, in the heroku_app_name field incredentials.yml
and in variables.tf.
- Replace the word
-
In the provider_heroku.tf insert your heroku email.
-
In the statuscake.tf insert your statuscace username.
-
Open the pipeline.yml and replace the git repo uri´s to your forked repo-uri´s.
-
-
Start Docker and concourse
- After all this setup remember to push your changes to your repo.
- I assume you have concourse downloaded and the fly CLI installed, now you
should run
docker-compose up -d
.
-
Start Fly/Concourse
-
Open a terminal and navigate to the Infra repository folder.
-
Run this command:
fly -t pgr301 login --concourse-url http://127.0.0.1:8080;
-
Then this:
fly -t pgr301 sp -p exam-infra -c concourse/pipeline.yml -l credentials.yml
- Open concourse by clicking on the link provided in the terminal.
-
Then run this:
fly -t pgr301 unpause-pipeline -p exam-infra
-
-
Start Build/Deploy
-
Navigate to the web browser and the concourse view
-
Click on the
Infra
-job and then trigger it. -
The
Build
-job should start by it self. -
You will now see
Build
andInfra
running. -
After they are done
Deploy
anddeploy-heroku-config-vars
should be automatically triggered.- This means that The infrastructure in Heroku is created, and The application is successfully built. Docker image is also deployed to heroku.
-
After
Deploy
anddeploy-heroku-config-vars
is done.- The application is now published and the hosted graphite enviornemt variables is added.
-
-
Enable Hosted Graphite
-
Now Open Heroku and navigate to the newly created pipeline. In here you will see 3 apps: Ci, Staging and Production.
- On each of the apps click on the Installed add on; Hosted Graphite, and copy the graphite url.
Then paste this in their respective variable in the
credentials.yml
file.
- On each of the apps click on the Installed add on; Hosted Graphite, and copy the graphite url.
Then paste this in their respective variable in the
-
Now run the command as described in task 5 again.
-
Trigger
Infra
once more to make use of the new Graphite variables.
-
-
Access the application
- Access the application by hitting
Open App
on theCi application inside Heroku.
- Remember to add
api/pokemon
to the url after hittingOpen App
.
- Remember to add
- You will as well be able to see all the apps in the pipeline in your StatusCake page.
- Here you can monitor your applications.
- When using this api you can use the DTO object you retrive from a GET request as a schama for making a POST or PUT request. You can use tools like Postman to make these requests.
- Access the application by hitting
- Basic Pipeline
- Docker
- Surveillance, Alert and Metrics
- Terraform bug fixed in Infrastructure
- Cached maven dependencies
Here I have created a pipeline with in total 4 jobs.
One responsible for createing the infrastructure, one for building the application and creating docker images. Another for Publishing the newly created docker image, and one last to insert Graphite environment variables.
I Have used Docker in this exam. It has been used to create Docker images, these have then been pushed to Heroku Container Registry. And from there Pushed to the Ci application/environment.
I have made use of three types of metrics:
- Meter
- Counter
- Timer
StatusCake is also implemented to listen to all three applications in the pipeline.
Graphite is implemented in all three applications as well.
As a bonus I have implemented a fix for the problem where Infrastructure will fail the second time It runs, this because git is complaining due to no changes to commit. This fix can be found in terraform.sh.
I have as well implemented caching for maven dependencies so the second time and beyond a build is triggered it won´t donwload the whole internet again.
For the application I have created a Pokemon API in Kotlin.
This API support the following endpoints and HTTP methods:
HTTP Method | URL | Metric implemented |
---|---|---|
[GET] | /api/pokemon | true |
[GET] | /api/pokemon{id} | true |
[GET] | /api/pokemon?type=Fire | true |
[POST] | /api/pokemon | true |
[PATCH] | /api/pokemon/{id} | false |
[PUT] | /api/pokemon/{id} | false |
[DELETE] | /api/pokemon/{id} | false |
For further development I Could have devided the jobs into smaller tasks.
I could also have tried to use Google Cloud or AWS instead of Heroku. Especially because Heroku has alot of limitations.
Further I would have created logs with Logz.io and made an even better API for testing with smoke tests etc.