25
Building a Docker-ized Microservice In Node, Using Ansible Irakli Nadareishvili, Director of Strategy, API Academy @inadarei

AnsibleBuilding a Docker-ized Microservice In Node, Using Ansible - AnsibleFest NY 2015

Embed Size (px)

Citation preview

Building a Docker-ized MicroserviceIn Node, Using Ansible

Irakli'Nadareishvili,'

Director'of'Strategy,'API'Academy

@inadarei

2 ©#2015#CA.#ALL#RIGHTS#RESERVED. @inadarei

Containers

Microservices

DevOps Automation

Being a Developer Has Never Been More Fun!

3 ©#2015#CA.#ALL#RIGHTS#RESERVED. @inadarei

Microservices: The Next Big Thing…

4 ©#2015#CA.#ALL#RIGHTS#RESERVED. @inadarei

What are Microservices?

5 ©#2015#CA.#ALL#RIGHTS#RESERVED. @inadarei

Martin Fowler:

6 http://martinfowler.com/articles/microservices.html

“We#cannot#say#there#is#a#formal#definition#of#the#microservicesarchitectural#style,#but#we#can#attempt#to#describe#what#we#see#as#common#characteristics#for#architectures#that#fit#the#label.#�

6 ©#2015#CA.#ALL#RIGHTS#RESERVED.

EVOLUTIONARY3DESIGN

Characteristics of a Microservice Architecture per Fowler:

COMPONENTIZATION3VIA3SERVICES

ORGANIZED3AROUND3BUSINESS3CAPABILITIES

PRODUCTS,3NOT33PROJECTS

SMART3ENDPOINTS3AND3DUMB3PIPES

DECENTRALIZED3GOVERNANCE3&3DATA3MANAGEMENT

1

2

3

4

5

INFRASTRUCTURE3AUTOMATION/DESIGN3FOR3FAILURE6

7

7 ©#2015#CA.#ALL#RIGHTS#RESERVED. @inadarei

In Essence:Microservice)Architectural)Style)is)an)architectural)style)where)a)complex)system)decomposed)into)a)collection)of)services)that)are:

1. Autonomous)and)independently)deployable2. Small)and)easily)replaceable.3. And)each)service)delivers)a)distinct)capability)of)the)system.

Single Responsibility Principlemeets

API-First Design

8 ©#2015#CA.#ALL#RIGHTS#RESERVED. @inadarei

Key Benefits of MicroservicesTechnology#HeterogeneityPartitioned#Scalability#(per#microservice)Independent#DeploymentsCompose6abilityOptimized#for#Replace6ability

1

2

3

4

5

9 ©#2015#CA.#ALL#RIGHTS#RESERVED. @inadarei

We Know It Is Popular:

10 ©#2015#CA.#ALL#RIGHTS#RESERVED. @inadarei

Microservice Architectureis complex

Uncomfortable truth:

11 ©#2015#CA.#ALL#RIGHTS#RESERVED. @inadarei

Monolith is brittle, but has order

12 ©#2015#CA.#ALL#RIGHTS#RESERVED. @inadarei

Microservices: High Degree of Freedom

13 ©#2015#CA.#ALL#RIGHTS#RESERVED. @inadarei

A Lot Of Things That Can Go Wrong

Gilt.com says)they)have)~450,microservices.)

Netflix is)also)in)several,hundred.)That's)a)very)high)degree)of)freedom)– many,)many)moving)parts.

14 ©#2015#CA.#ALL#RIGHTS#RESERVED. @inadarei

How do we afford so many servers?

15 ©#2015#CA.#ALL#RIGHTS#RESERVED. @inadarei

Microservices Deployment Topology

Tanker1

12

34

Tanker2

12

33

Tanker3

1

23

4

Tanker4

1

34

16 ©#2015#CA.#ALL#RIGHTS#RESERVED. @inadarei

Microservices Are Not Free Lunch

17 ©#2015#CA.#ALL#RIGHTS#RESERVED. @inadarei

Microservices Deployment Topology

Tanker1

12

34

Tanker2

12

33

Tanker3

1

23

4

Tanker4

1

34

18 ©#2015#CA.#ALL#RIGHTS#RESERVED. @inadarei

How Do We Know Where Everything Is?1. Hashicorp Consul – multiGdataGcenter!

(Vagrant))G https://www.consul.io/

2. CoreOS')etcdhttps://github.com/coreos/etcd

3. Kubernetes by)Googlehttp://kubernetes.io/

4. Mesos DNS)https://github.com/mesosphere/mesosGdns

5. Apache)Zookeeperhttps://zookeeper.apache.org/

19 ©#2015#CA.#ALL#RIGHTS#RESERVED. @inadarei

Microservice Discovery Topology

Tanker1

12

34

Tanker2

12

33

Tanker3

1

23

4

Tanker4

1

34

Consul3Server3C

luster

ms1.service.consul

20 ©#2015#CA.#ALL#RIGHTS#RESERVED. @inadarei

For#the#sake#of#this#demo#we#use#Docker NginxProxy#– lifesaver#for#local#(dev)#setups.#But#in#production,#we#would#use#separate#Nginxcluster#and#Consul#Template

Our Deployment PlanConsul#Server#Cluster#(3#servers)Consul#Clients#(2#servers#w/#Consul#Template)DNSMasq on#Consul#ServersProvision#Docker Hosts#(Tankers)Install#Node.js Microservice#from#docker.io

1

2

3

4

5

http://nodebootstrap.io

21 ©#2015#CA.#ALL#RIGHTS#RESERVED. @inadarei

github.com/apiacademy/ansible-consul-demo

22 ©#2015#CA.#ALL#RIGHTS#RESERVED. @inadarei

github.com/apiacademy/ansible-consul-demo

23 ©#2015#CA.#ALL#RIGHTS#RESERVED. @inadarei

github.com/apiacademy/ansible-consul-demo

24 ©#2015#CA.#ALL#RIGHTS#RESERVED. @inadarei

github.com/apiacademy/ansible-consul-demo

DEMO TIME

Director#of#Strategy,#API#Academy

Irakli3Nadareishvili

@inadarei

@apiacademy

@cainc