Coder Social home page Coder Social logo

devopstask's Introduction

Introduction:

This project creates all the infrastructure needed to build & deploy a dockerized microservice with a REST api. The only path available is http://EC2_SERVER:9000/jokes. It returns the last 100 jokes from bash.org.pl in JSON format. The project has been developed in a linux machine with Debian 11.

Project dependencies:

  • docker 20.10.17
  • docker-compose 2.9.0
  • aws-cli 2.2.43
  • ansible 2.13.2
  • terraform 1.2.4
  • golang 1.18

Project Setup:

  • Create a file ansible/.vault_pass and set the vault password

  • Add your AWS credentials e.g:

export AWS_ACCESS_KEY_ID="AJDJSFHSDJHSDJHSDBF"
export AWS_SECRET_ACCESS_KEY="SLJKSFJHSFEFBNFBFDFBSF"
  • Run ./create-infrastructure.sh to generate all required resources

Run the REST api locally:

make recreate-app

To query the api:

curl localhost:9000/jokes

Run Jenkins locally:

make recreate-jenkins

To build the app for different environments:

ENV=develop TAG=mytag make build-app

Jenkins multibranch pipeline:

A multibranch pipeline will be automatically generated in jenkins when the infrastructure gets created. develop branch will be deployed in: https://EC2_INSTANCE_DNS:9000 release branch will be deployed in: https://EC2_INSTANCE_DNS:9001 main branch will be deployed in: https://EC2_INSTANCE_DNS:9002

Once a PR is merged into the main branch, the Jenkins pipeline will tag the repo with Semantic versioning, increasing the patch version. The major and minor versions can be incremented specifying the text #major or #minor in commit message.

Project structure:

|-- ansible: Ansible playbook to setup the EC2 machine
|-- app-devops-task: Golang app that exposes a REST api in localhost:9000/jokes
|-- docker-compose: Docker compose templates to deploy the api and Jenkins
|-------- app: Docker compose template for deploying the REST api
|-------- jenkins: Docker compose template for deploying Jenkins
|-------------- secrets.env Contains an ansible vault with passwords
|
|-- terraform: IAC to create a VPC, IGW, Public subnet, Security Group and EC2 instance. 
               It launches the ansible playbook too. 

Tech Task description:

Create a microservice serving REST API with GET calls returning 100 jokes starting from the newest from bash.org.pl in JSON format; service must be created and launched in Docker container. Create Terraform code for provisioning custom VPC + EC2 and proper Security Groups to allow access to the services from the Internet using specific port (for example to execute curl to get the response or reach Jenkins) Create Ansible playbook to install required libraries, os updates and tools on the EC2 instance and Jenkins before the microservice deployment Deploy the microservice on AWS EC2 using CI/CD (Jenkins) and gitflow. Jenkins can be installed on the same instance as the microservice. Place all codes for Terraform, Ansible and the microservice on Github repository + access to Jenkins for the verification.

devopstask's People

Contributors

samirachosentryc avatar samiracho avatar

Watchers

James Cloos avatar  avatar

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.