Skip to content

colinbut/microservices-template

Repository files navigation

Microservices Template

++ Note: This project is still WIP ++

This repo contains a skeleton template for creating new microservices.

It is an opinionated template where certain technology/tool/framework have been chosen...

High Level Architecture

microservices-template

Programming Language

  • Java 8

Application Framework

  • Spring Boot 2.0+

Build

Both Maven and Gradle are supported. However, Maven is currently the main build system used for this project to manage the release.

Maven
Maven wrapper is used so that no need to install Maven on your machine beforehand. Lets maven wrapper take care of maven.

Gradle
Just like Maven, Gradle offers the Gradle wrapper is used so that no need to install Gradle on your machine beforehand.

Continuous Integration (CI)

See Jenkinsfile which is a config file for defining build settings on Jenkins 2.0+ (with the use of Pipelines).

Only Jenkins 2.0+ is supported.

Continuous Delivery (CD)

Every commit/merge is a RC (Release Candidate).

See Jenkinsfile's section on Continous Delivery.

Continuous Deployment (CD)

Mainly it is about the automated deployment from a testing environment (Staging) onto live Production. Normally, or historically, this would be a manual process done by the Operations Team (Ops).

See Jenkinsfile's section on Continous Deployment.

CD is facilitated by the shell script deploy.sh which you can use and edit to define the steps and behaviours for doing the deployment. In Jenkins pipeline, we have a sanity check stage which governs or acts as a gate prior for the software to be deloyed onto Production. (Artifact/Pipeline promotion).

Infrastructure As Code

To implement IAC, Terraform is used. You can place your terraform files in the terraform directory. This template assumes the project will be deployed onto the Cloud or to any other infrastructure that is supported by Terraform.

If deploying to a bare metal physical server machine or to Virtual Machines, one might decide to use a configuration management tool such as Ansible, Puppet, or Chef a like to automate the provisioning of the infrastructure instead. Currently this template does not offer support for this. As normally, these deployment methods normally reside in a separate source code repository hence this subject matter is out of the scope of this template project.

Deploymemt

Docker

See Dockerfile in the root of the project directory.

Building a Docker container

./mvnw clean package

or execute Docker directly:

docker build -t microservices-template:1.0.0-SNAPSHOT .

Kubernetes

Using an container orchestration framework to manage the containers. This template project is opinionated towards Kubernetes. It is to note that other container orchestration platforms exists (Docker Swarm, Nomad with Consul, Apache Mesos on DC/OS etc).

kubectl apply -f deployment/microservices-template.yml

API Documentation

Use of Swagger to document our microservice's API REST endpoints.

Access Swagger on:

http://{microservices-template-service-url}:{port}/swagger-ui.html