corkdev.io - service discovery with microservices and docker

15
techblog.newsweaver.com github.com/PierreVincent @PierreVincent pierrevincent Microservices, Docker & Service Discovery with Smartstack Oct 13th 2015 This work is licensed under a Creative Commons Attribution 4.0 International Li cense . newsweaver

Upload: pierre-vincent

Post on 15-Apr-2017

635 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: CorkDev.io - Service discovery with Microservices and Docker

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

Page 2: CorkDev.io - Service discovery with Microservices and Docker
Page 3: CorkDev.io - Service discovery with Microservices and Docker

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

Building Microservices

Page 4: CorkDev.io - Service discovery with Microservices and Docker
Page 5: CorkDev.io - Service discovery with Microservices and Docker

Development

Staging

Production Servers

Dev

Registry

(git)

(build server)

Page 6: CorkDev.io - Service discovery with Microservices and Docker

A A

A A

B B

B B

X

Page 7: CorkDev.io - Service discovery with Microservices and Docker

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

Smartstack

Page 8: CorkDev.io - Service discovery with Microservices and Docker

Zookeeper

Application

Viewing History Service

API Application

Recommendations Service

SynapseHAProxyNerve

Publication Discovery

SmartstackOverview

Page 9: CorkDev.io - Service discovery with Microservices and Docker

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

Page 10: CorkDev.io - Service discovery with Microservices and Docker

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

Page 11: CorkDev.io - Service discovery with Microservices and Docker

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

Page 12: CorkDev.io - Service discovery with Microservices and Docker

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

Page 13: CorkDev.io - Service discovery with Microservices and Docker

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

Page 14: CorkDev.io - Service discovery with Microservices and Docker

Some reading...

Page 15: CorkDev.io - Service discovery with Microservices and Docker

techblog.newsweaver.com

Questions ?

@PierreVincent