48
Bernd Zuther | codecentric AG Von Null auf Hundert mit Microservices

Von Null auf Hundert mit Microservices

Embed Size (px)

Citation preview

Page 1: Von Null auf Hundert mit Microservices

BerndZuther|codecentricAG

VonNullaufHundertmitMicroservices

Page 2: Von Null auf Hundert mit Microservices
Page 3: Von Null auf Hundert mit Microservices
Page 4: Von Null auf Hundert mit Microservices
Page 5: Von Null auf Hundert mit Microservices
Page 6: Von Null auf Hundert mit Microservices

Data

Functionality

Microservice

6/45

Page 7: Von Null auf Hundert mit Microservices

Data

Functionality

Microservice

fitsinonebrain,

·

6/45

Page 8: Von Null auf Hundert mit Microservices

Data

Functionality

Microservice

fitsinonebrain,designedforreplaceability,

·

·

6/45

Page 9: Von Null auf Hundert mit Microservices

Data

Functionality

Microservice

fitsinonebrain,designedforreplaceability,autonomy(organisation&technology)

·

·

·

6/45

Page 10: Von Null auf Hundert mit Microservices

MicroserviceTaxonomyMicroservice

ApplicationFrontend

ServiceService

Repository/Orchestration

ServiceDiscovery

Contract Implementation Interface

BusinessLogic

Data

Monitoring/Logging

7/45

Page 11: Von Null auf Hundert mit Microservices

MicroserviceArchitecture

Page 12: Von Null auf Hundert mit Microservices

Processesbz@cc:~/$psauxwww-data16990.57.72453320158076?Sl10:490:26java-cpcart.jarwww-data18340.35.02435400102684?Sl10:490:17java-cpnavigation.jarwww-data19720.00.1907923124?Ss10:490:00nginx:masterprocesswww-data19730.00.1911483820?S10:490:00nginx:workerprocesswww-data19740.00.1911483820?S10:490:00nginx:workerprocesswww-data19750.00.1911483820?S10:490:00nginx:workerprocesswww-data19760.00.1911483820?S10:490:00nginx:workerprocesswww-data19801.57.02456532143688?Sl10:491:20java-cpproduct.jar

BASH

9/45

Page 13: Von Null auf Hundert mit Microservices

OnlineShop-Deployment

<<device>>Microservice Server

<<web server>>Ngnix

<<service>>Cart Service

<<service>>Product Service

<<device>>Monolith Server

<<application server>>Tomcat

<<artifact>>shop.war

<<artifact>>Catalog View

<<artifact>>cart-service.jar

<<artifact>>product-

service.jar

Cart Catalog

Product

10/45

Page 14: Von Null auf Hundert mit Microservices
Page 15: Von Null auf Hundert mit Microservices

LinuxPackagesbz@cc:~/$artcart_0.6.20.debdebian-binarycontrol.tar.gzdata.tar.gzbz@cc:~/$tartzfdata.tar.gz./etc/default/cart./etc/init.d/cart./usr/share/shop/cart/bin/cart./usr/share/shop/cart/bin/cart.bat./usr/share/shop/cart/lib/cart-microservice-0.6.20.jarbz@cc:~/$tartzfcontrol.tar.gz./postinst./control./md5sumsbz@cc:~/$catdebian-binary2.0

BASH

12/45

Page 16: Von Null auf Hundert mit Microservices

ControlFileSource:shop-cart-serviceSection:webPriority:optionalVersion:4.2.42Maintainer:BerndZutherHomepage:http://www.bernd-zuther.de/Vcs-Git:https://github.com/zutherb/AppStash.gitVcs-Browser:https://github.com/zutherb/AppStashPackage:shop-cart-serviceArchitecture:amd64Depends:redis-server(>=2.8.13)Description:CartService

VIM

13/45

Page 17: Von Null auf Hundert mit Microservices

PackageSourceBuildserver

Provision

reprepro-Vb/var/packages/debianincludedebshop/tmp/*.debreprepro-b/var/packages/debian/exportreprepro-b/var/packages/debian/listshop

BASH

----apt_repository:repo='debhttp://ci-repo/debian/shopmain'state=present-apt:update_cache=yesforce=yes-apt:pkg={{item}}state=presentforce=yeswith_items:-shop-cart-service

YAML

14/45

Page 18: Von Null auf Hundert mit Microservices

LinuxPackages

Pro Contra

ServiceRepository NoServiceDiscovery

DependencyManagement Runtimeenviromentmustbecreatedoneverysinglenode

Technologiesarebattle-tested Dependsonthelinuxdistribution

Page 19: Von Null auf Hundert mit Microservices
Page 20: Von Null auf Hundert mit Microservices

Docker

Page 21: Von Null auf Hundert mit Microservices

Docker-FileFROMrelateiq/oracle-java8MAINTAINERBerndZuther<[email protected]>EXPOSE18080ADDproduct-0.6.tar/ENTRYPOINT["/product-0.6/bin/product"]

BASH

Page 22: Von Null auf Hundert mit Microservices

Docker-Workflowbz@cc1$dockerbuild-tzutherb/product-service.bz@cc1$dockerpushzutherb/product-servicebz@cc2$dockerpullzutherb/product-servicebz@cc2$dockerrunzutherb/product-servicebz@cc2$dockerpsCONTAINERIDIMAGECOMMANDCREATED87bb5524067dzutherb/product-service:latest"/product-0.6/bin/pr14seconds

BASH

Page 23: Von Null auf Hundert mit Microservices

DeploymentScenario

<<device>>Docker Deamon

<<container>>Ngnix

<<container>>Cart Service

<<container>>Product Service

<<artifact>>checkout

.war

<<artifact>>catalog.tar

<<artifact>>cart-service.jar

<<artifact>>product-

service.jar

<<container>>Tomcat

<<container>>MongoDB

<<container>>Redis

<<container>>Navigation

Service

<<artifact>>navigation-service.jar

Page 24: Von Null auf Hundert mit Microservices

Linkingbz@cc~$dockerrun-d--namemongodbmongo705084daa3f852ec796c8d6b13bac882d56d95c261b4a4f8993b43c5fb2f846cbz@cc~$dockerrun-d--nameredisredis784ebde0e867adb18663e3011b3c1cabe990a0c906396fc306eac669345628cfbz@cc~$dockerrun-d-P--namecart--linkredis:rediszutherb/cart-service438b2657c7a5c733787fb32b7d28e1a0b84ba9e10d19a8a015c6f24085455011bz@cc~$dockerrun-d-P-p8080:8080--nameshop--linkcart:cart\--linkmongodb:mongodbzutherb/monolithic-shop9926e187faa215ac9044603d51adbd8d679d8076b4a349ebbc9917dade6d560ebz@cc$dockerexec9926e187faa215ac9044603d51adbd8d679d8076b4a349ebbc9917dade6d560eenvPATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binHOSTNAME=87bb5524067dMONGODB_PORT_27017_TCP=tcp://172.17.0.28:27017MONGODB_PORT_27017_TCP_ADDR=172.17.0.28MONGODB_PORT_27017_TCP_PORT=27017MONGODB_PORT_27017_TCP_PROTO=tcp

BASH

Page 25: Von Null auf Hundert mit Microservices
Page 26: Von Null auf Hundert mit Microservices

DockerComposeredis:image:dockerfile/redisports:-"6379:6379"cart:image:eshop/cart-serviceports:-"18100:18100"links:-rediscatalog:image:eshop/catalog-frontendports:-"80:80"links:-product-cart

YAML

23/45

Page 27: Von Null auf Hundert mit Microservices

Docker

Pro Contra

Applicationsareisolated Daemonrunsasrootonhost

Imagesarebuiltonceandrunanywhere NoProcessSupervisor

DockerRepository NoServiceDiscovery

Bigecosystem(Kubernetes,Mesos,Vamp)

Page 28: Von Null auf Hundert mit Microservices

BlueGreenDeployment

Old Version

WebServer

ApplicationServer

DatabaseServer

New Version

WebServer

ApplicationServer

DatabaseServer

RouterUsers

25/45

Page 29: Von Null auf Hundert mit Microservices

CanaryRelease

Old Version

WebServer

ApplicationServer

DatabaseServer

New Version

WebServer

ApplicationServer

DatabaseServer

RouterUsers

95%

5%

26/45

Page 30: Von Null auf Hundert mit Microservices

Microservice-CanaryReleaseOld Version

WebServer

ApplicationServer

DatabaseServer

New Version

WebServer

ApplicationServer

DatabaseServer

RouterUsers

Old Version

WebServer

ApplicationServer

DatabaseServer

New Version

WebServer

ApplicationServer

DatabaseServer

Old Version

WebServer

ApplicationServer

DatabaseServer

New Version

WebServer

ApplicationServer

DatabaseServer

27/45

Page 31: Von Null auf Hundert mit Microservices
Page 32: Von Null auf Hundert mit Microservices

DistributedSystem

ResourceAllocator

Executor Executor Executor

Scheduler

Docker Repository

29/45

Page 33: Von Null auf Hundert mit Microservices

Kubernetes

Kublet Info Service

Kublet Kublet Kublet

API Server

Docker Repository

Scheduler

ResourceAllocator

Executor

30/45

Page 34: Von Null auf Hundert mit Microservices

PodapiVersion:v1kind:Podmetadata:labels:name:cartrole:backendname:cartspec:containers:-name:cartimage:zutherb/cart-serviceports:-containerPort:18100

YAML

31/45

Page 35: Von Null auf Hundert mit Microservices

ReplicationControllerapiVersion:v1kind:ReplicationControllermetadata:...(labels)spec:replicas:2selector:name:carttemplate:metadata:...(labels)spec:containers:-name:cartimage:zutherb/cart-serviceports:-containerPort:18100

YAML

32/45

Page 36: Von Null auf Hundert mit Microservices

Service

33/45

Page 37: Von Null auf Hundert mit Microservices

Servicekind:ServiceapiVersion:v1metadata:labels:name:cartrole:backendname:cartspec:ports:-name:cartport:18100selector:name:cart

YAML

34/45

Page 38: Von Null auf Hundert mit Microservices

Kubernetes

Pro Contra

Youneedn'tcarewhereworkisexecuted Nodescriptionofthewholeapplication(incontrasttodockercompose)andfordeploymentscenario

Youneedn'tcareaboutdependencies Failureanalysiswillgetharder

Servicediscovery Masterisasinglepointoffailure

ProcessSupervisor Fewtoolsanddocumentationisavaiableyet

Page 39: Von Null auf Hundert mit Microservices

Mesos

MesosMaster

MesosSlave

MesosSlave

MesosSlave

Marathon

Docker Repository

Scheduler

ResourceAllocator

Executor

Standby MesosMaster

Standby MesosMaster

Zookeeper

36/45

Page 40: Von Null auf Hundert mit Microservices

MarathonDeployment{"id":"basic-3","cmd":"python3-mhttp.server8080","cpus":0.5,"mem":32.0,"container":{"type":"DOCKER","docker":{"image":"python:3","network":"BRIDGE","portMappings":[{"containerPort":8080,"hostPort":0}]}}}

YAML

curl-XPOSThttp://10.141.141.10:8080/v2/[email protected]\-H"Content-type:application/json"

BASH

37/45

Page 41: Von Null auf Hundert mit Microservices

Marathon+Mesos

Pro Contra

Youneedn'tcarewhereworkisexecuted Nodescriptionofthewholeapplicationandfordeploymentscenario

HighAvailability NoServiceDiscovery

ProcessSupervisor Failureanalysiswillgetharder

Manytoolsanddocumentationareavailable

Page 42: Von Null auf Hundert mit Microservices

VeryAwesomeMicroservicesPlatform(Vamp)

39/45

Page 43: Von Null auf Hundert mit Microservices

Vamp+Marathon+Mesos

Pro Contra

Descriptionofthewholeapplicationandfordeploymentscenario

Manycomponentsthathavetobeunderstood

Youneedn'tcarewhereworkisexecuted Failureanalysiswillgetharder

HighAvailability

ProcessSupervisor

ServiceDiscovery

Page 44: Von Null auf Hundert mit Microservices

Summary LinuxPackages DockerDaemon Kubernetes Vamp+Marathon+

Mesos

ServiceRepository

Orchestration (<100)

ServiceDiscovery

ProcessSupervisor

HighAvailability

ApplicationDescription

RoutingDefinition

Page 45: Von Null auf Hundert mit Microservices

<ThankYou!>

g+ plus.google.com/+BerndZuthertwitter @Bernd_Zwww bernd-zuther.degithub github.com/zutherb/

Page 46: Von Null auf Hundert mit Microservices

Demo+SlidesApplication

Page 47: Von Null auf Hundert mit Microservices

LinksJavaAktuell02/15-MicroservicesunddieJagdnachmehrKonversionMicroservice-DeploymentganzeinfachmitGiantSwarmMicroservice-DeploymentganzeinfachmitKubernetesMicroservice-DeploymentganzeinfachmitDockerComposeMicroservice-DeploymentganzeinfachohneDockermitderLinux-PaketverwaltungCanaryReleasemitderVeryAwesomeMicroservicesPlatformLeanStartupTestDrivenBusinessFeaturingLeanStartUpContinuousDeliverymitdemFeatureTogglePatternFeatureToggleDoGoodMicroservicesArchitecturesSpelltheDeathoftheEnterpriseServiceBus?Microservices

·····

······

·44/45

Page 48: Von Null auf Hundert mit Microservices

LinksTheTwelveFactorsMicroservicesimZusammenspielmitContinuousDelivery,Teil1–dieTheorieFast,isolateddevelopmentenvironmentsusingDockerWarnungvordemMicroservice–VersucheinerDefinitionMicroServicesinderPraxis:NiewiederMonolithen!Deploymentganzeinfach–MicroserviceDeploymentmitHilfederLinuxPaketverwaltungSplunk–MarkeEigenbaumitElasticsearch,LogstashundKibana(ELKStack)ScalingDockerwithKubernetesContainer-Technik:Docker&Co.AppstashProject

······

····

45/45