corkdev.io - service discovery with microservices and docker

Post on 15-Apr-2017

635 Views

Category:

Technology

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

techblog.newsweaver.com

github.com/PierreVincent

@PierreVincent

pierrevincent

Microservices, Docker & Service Discovery

with SmartstackOct 13th 2015

This work is licensed under a Creative Commons Attribution 4.0 International License.

newsweaver

Microservices are small, autonomous services that work together. Sam Newman

Building Microservices

Development

Staging

Production Servers

Dev

Registry

(git)

(build server)

A A

A A

B B

B B

X

github.com/airbnb/nervegithub.com/airbnb/synapse

Smartstack

Zookeeper

Application

Viewing History Service

API Application

Recommendations Service

SynapseHAProxyNerve

Publication Discovery

SmartstackOverview

Application

Nerve

ZK

1.1.1.1

nerve.confname = viewing_historyip = 1.1.1.1port = 8080healthCheck = /health

Publication

SmartstackNerve

API(8080)

/health

Viewing History Service

Application

Synapse

ZK

1.1.1.2

synapse.confviewing_history → 9000

Discov

ery

SmartstackSynapse

HAProxy

1.1.1.1

haproxy.confviewing_history: frontend: localhost:9000 backends: [1.1.1.1:8080]

GEThttp://localhost:9000/users/123/viewingHistory

8080 Servicesviewing_history: [1.1.1.1:8080]

Recommendations Service

ping

Base(ex. Ubuntu)

ruby

synapse (gem)HA Proxy

nerve (gem)

service.jarsynapse.conf / nerve.conf

startup script

JS files

startup script

Smartstack Base

startSynapse.shstartNerve.sh

+ Tech

synapse.conf / nerve.conf + Service code+ Config

FROM newsweaver/smartstack-java

# DiscoveryADD nerve.conf.json /etc/ADD synapse.conf.json /etc/

# JARADD service.jar /opt/service/

# StartupADD start.sh /opt/start.shENTRYPOINT ["/opt/start.sh"]

Dockerfile

#!/bin/bash

/opt/startSynapse.sh/opt/startNerve.sh

java -jar /opt/service/service.jar

start.sh

$ docker build -t my-service ....$ docker run -d -e ZK_HOSTS=zk1:2181,zk2:2181 my-service

color-service

color-service

color-serviceGET .../v1/color

color-ui-service

blue

{ "name": "blue", "hex": "0000FF"}

{ "name": "red", "hex": "FF0000"}

{ "name": "green", "hex": "00FF00"}

Demo !github.com/PierreVincent/discovery-demo-color

Some reading...

techblog.newsweaver.com

Questions ?

@PierreVincent

top related