Giter Club home page Giter Club logo

micro-service-as-code's Introduction

Infrastructure as Code for a Micro Service Environment (PoC)

This is a proof of concept for micro service IaC environment where everything related to the service is self contained in the service repository.

This repository will use EC2 instances to deploy the service but we can easily swap this by a kubernetes cluster (commonly used in micro-services environment). We are going to use EC2 instances here to reduce dependencies in this PoC.

This infrastructure is coded as a module so we can run end to end tests using test-kitchen.

Micro Service

The micro service is a basic Hello World! node app replying Pong! if you call /ping. The point of having a node app is simply to show a full end to end pipeline from app code to running application. We could adapt this for any language or app as long as we adapt the test and building steps.

The application has a /health endpoint which occasionally return 500 (10% of the time).

Tools

The service is published on Docker Hub gbergere/micro-service-as-code then deployed via terraform on EC2 instances. I would ideally love to deploy it on Kubernetes (reason why I build a Docker container) but for now we keep dependencies simple.

  • TravisCI
  • Docker and DockerHub (with multi-stage build)
  • GitHub (as you can see)
  • Terraform
  • Test Kitchen (to test Infrastructure as Code)
  • AWS (to run the service)
  • CoreOS (with cloud-config)

FAQ

Can we run this service in production as it is?

This is done as a terraform module so we can run tests on terraform (fairly easily). If we would like to deploy this in production we would simply have to call this module in a terraform project to create the stack (and deploy the version defined in the module call). You can see a small example in the test/fixtures/wrapper directory calling this module to test it with test-kitchen terraform.

How to deploy a new version?

To deploy a new version on the application you simply need to apply terraform with a new app_version value on the module call. This will trigger a rolling deployment with terraform in an immutable infrastructure still with a rotation of the autoscaling group. The application won't have any down time.

micro-service-as-code's People

Contributors

gbergere avatar

Stargazers

Morgan Bruce avatar

Watchers

James Cloos 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.