Microservices & Containers - Docker Bangalore Meetup #12

21
© 2015 ARAVIND AJAD YARRA < 1 > MICROSERVICES & CONTAINERS making services work μ

Transcript of Microservices & Containers - Docker Bangalore Meetup #12

Page 1: Microservices & Containers - Docker Bangalore Meetup #12

© 2015 ARAVIND AJAD YARRA < 1 >

MICROSERVICES & CONTAINERS

mak ing se rv i ces work

μ

Page 2: Microservices & Containers - Docker Bangalore Meetup #12

© 2015 ARAVIND AJAD YARRA < 2 >

ARAVIND AJAD YARRA

Software Architect & Engineer for 19 years

Distinguished Member of Technical Staff at Wipro

Page 3: Microservices & Containers - Docker Bangalore Meetup #12

© 2015 ARAVIND AJAD YARRA < 3 >

MICROSERVICESQUICK INTRODUCTION TO MICROSERVICES

Page 4: Microservices & Containers - Docker Bangalore Meetup #12

© 2015 ARAVIND AJAD YARRA < 4 >

SOA CURRENT STATE

ORCEHSTRATION

BUSINESS LOGIC

CHANNELS OLTP WORK-FLOWDASH

BOARDS

CORE SYSTEMSLEGACY

SYSTEMSDATA

WAREHOUSESPARTNER SYSTEMS

ENTERPRISE SERVICE BUS

GOVERNANCE

CONNECTIVITY

SERVICEPROVIDERS/

CLIENTS

SERVICECLIENTS/

PROVIDERS

SOA INTEGRATIONMIDDLEWARE

Service Oriented Architectures are currently adopted in Enterprise Integration.

Page 5: Microservices & Containers - Docker Bangalore Meetup #12

© 2015 ARAVIND AJAD YARRA < 5 >

MONOLITH ARCHITECTURE

RWD MVC

Quote HomeCommercial

Cross SellCart Rules Ref Data Bundles

ResumeCaching Document Payment Integration

Validations

Auto

Data Store

Life

UI

JAVA

EE

CO

NTA

INER

Monolith architectures have components bundled together with tight dependencies. Change or failure in a component will result in fragility, there by makes it difficult to evolve the architecture.

Page 6: Microservices & Containers - Docker Bangalore Meetup #12

© 2015 ARAVIND AJAD YARRA < 6 >

MICROSERVICES

Hom

e Q

uote

Com

mer

cial

Quo

te

Reco

mm

enda

tions

Cart

Bund

le M

anag

emen

t

Caching Document

Paym

ent

Auto

Quo

te

μ μ μ μ μ μ

μ μμ

• Service Oriented

• Independently managed

• Loose Coupling

• Connected

Applying service oriented architecture principles to monolith system architectures

Page 7: Microservices & Containers - Docker Bangalore Meetup #12

© 2015 ARAVIND AJAD YARRA < 7 >

WHY CONTAINERS?PRACTICAL CONSIDERATIONS FOR MICROSERVICES

Page 8: Microservices & Containers - Docker Bangalore Meetup #12

© 2015 ARAVIND AJAD YARRA < 8 >

KEY CONSIDERATIONS

DesignDeploymen

tConfiguratio

n Discovery Manage

Design and development of

services - Service capabilities such as

connectivity, discovery and

monitoring

Deploy self-contained services.

Continuous deployment of

services – enable evolution & continuous availability

Configure services externally without fixed assumptions

Transparently discover

dependent services. Find failed services

and connect to resumed services.

Manage services and Monitor service

specific metrics, events and logs

Page 9: Microservices & Containers - Docker Bangalore Meetup #12

© 2015 ARAVIND AJAD YARRA < 9 >

KEY CHALLENGES

Design

Deployment

Configuration

Discovery

Manage

• Lightweight – How not to add overhead?

• Self-contained – How do we make services portable across environments? How do we isolate service processes?

• Continuous deployment – How to deploy services rapidly without any disruption?

• Setup & Discovery – How to setup services and add dependencies?

• Elastic Scaling - How to scale services transparently?

• Monitor – How to monitor services and failures?

Application Stacks have grown up to handle these. How about infrastructure?

Page 10: Microservices & Containers - Docker Bangalore Meetup #12

© 2015 ARAVIND AJAD YARRA < 10 >

DOCKER MADE FOR μS

Docker makes an excellent choice for micro-services. But is it enough?

• Isolation : One process per container

• Lightweight : No virtualization overhead

• Self-contained : Package all the hard dependencies together

• Portable : Easily pull images into any environment

Page 11: Microservices & Containers - Docker Bangalore Meetup #12

© 2015 ARAVIND AJAD YARRA < 11 >

CONTAINER ORCHESTRATIONOrchestrate containers to facilitate micro-services architecture Provision Containers Manage Container Dependencies Enable Discovery Handle Container Failure Scale Containers

Amazon ECS

Page 12: Microservices & Containers - Docker Bangalore Meetup #12

© 2015 ARAVIND AJAD YARRA < 12 >

BRINGING IT ALL TOGETHERHOW TO MAKE ALL THIS WORK?

Page 13: Microservices & Containers - Docker Bangalore Meetup #12

© 2015 ARAVIND AJAD YARRA < 13 >

KUBERNETES CLUSTER

Master

Minion

pod pod

labels labels

kubelet

cAdvisor proxy

API Server

Minion

pod pod

labels labels

kubelet

cAdvisor proxy

scheduler

replication

controller

kubectl

distributed storage

Page 14: Microservices & Containers - Docker Bangalore Meetup #12

© 2015 ARAVIND AJAD YARRA < 14 >

PACKAGING μS • Packaging a microservice involves creating a executable JAR or

equivalent. Use Onejar or Spring Boot to build a fat jar with all dependencies

• Create Docker image with the executable for microservice. Use caching as required

• Pod is the abstraction for a basic unit of a μS in Kubernetes. Create a Pod with docker image.

Page 15: Microservices & Containers - Docker Bangalore Meetup #12

© 2015 ARAVIND AJAD YARRA < 15 >

SCALING μS• Replicating Pods is easy and will replicate containers (&

microservices)• Kubernetes replication controllers are best way to achieve

replication

• Replica count can be incremented or decremented as required dynamically using kubectl or Kubernetes API

• BTW, replication controllers can help in resiliency

Page 16: Microservices & Containers - Docker Bangalore Meetup #12

© 2015 ARAVIND AJAD YARRA < 16 >

LOAD BALANCING• Load balancing can be enabled using the ‘Service’ construct of

Kubernetes. Service is essentially a proxy on top of Pod.

kube-proxy

Pod #2

Labels: quoteservicePort: 8080

Pod #3

Labels: quoteservicePort:8080

Pod #1

Labels: quoteservicePort:8080

• Load balancing is done using selectors on labels • Pods are ephemeral and they can come up and go. Service will

resolve those pods randomly.

Page 17: Microservices & Containers - Docker Bangalore Meetup #12

© 2015 ARAVIND AJAD YARRA < 17 >

BG DEPLOYMENT

service

Pod #2

Labels: quoteservice

Port: 8080

Pod #3

Labels: quoteservice

Port:8080

Pod #1

Labels: quoteservice

Port:8080

service

Pod #2

Labels: quoteservice

Port: 8080

Pod #3

Labels: quoteservice

Port:8080

Pod #1

Labels: quoteservice

Port:8080

X

Pod #4

Labels: quoteservice

Port:8080

Services enables blue-green deployments for continuous deployment Services also enable other patterns such as canary releases, taking

off instances for debugging and so on

repl co

ntr

olle

r #

1#

2

Page 18: Microservices & Containers - Docker Bangalore Meetup #12

© 2015 ARAVIND AJAD YARRA < 18 >

SERVICE DISCOVERY Environment Variables

kubelet adds environment variables for every service that is active in the cluster

microservices can leverage these environment variables for resolving dependencies

SkyDNS with DNS cluster add-on Injects SkyDNS (+etcd) to environment variables SkyDNS is populated with active services from

kubernetes master Higher order frameworks

Consul Eureka

Page 19: Microservices & Containers - Docker Bangalore Meetup #12

© 2015 ARAVIND AJAD YARRA < 19 >

SERVICE MONITORING Docker Process Monitoring

Kubelet monitors docker process constantly Failure of docker process triggers restart of the pod

based on policy Application Level Health Checks

HTTP Health Check – Kubelet calls a HTTP endpoint Container Exec – Kubelet calls a container command

Higher Order Frameworks Hystrix + Eureka

Metrics & Log Monitoring Heapster Fluentd + Elasticsearch

Page 20: Microservices & Containers - Docker Bangalore Meetup #12

© 2015 ARAVIND AJAD YARRA < 20 >

WATCH OUT

Orchestration of containers for stateful microservices

Limited controller capabilities

Rapidly evolving Not yet ready for production

Limited management capabilities Tooling is yet to catch-up

Read the small print

Page 21: Microservices & Containers - Docker Bangalore Meetup #12

© 2015 ARAVIND AJAD YARRA < 21 >

THANK YOU

@aravindajad

www.slideshare.net/AravindAjad

MAERSK CREATIVE COMMONS