92
Daniël van Gils Developer Advocate @foldingbeauty [email protected] www.cloud66.com Running Microservices in Production with Docker

How do I run microservices in production using Docker

Embed Size (px)

Citation preview

Page 1: How do I run microservices in production using Docker

Daniël van Gils Developer Advocate

@foldingbeauty [email protected]

www.cloud66.com

!

"

Running Microservices in Production with Docker

Page 2: How do I run microservices in production using Docker

= public/private/hybrid = yours

Services

#

> 4000 serversEasy Ops tools build for Devs

Page 3: How do I run microservices in production using Docker
Page 4: How do I run microservices in production using Docker
Page 5: How do I run microservices in production using Docker
Page 6: How do I run microservices in production using Docker
Page 7: How do I run microservices in production using Docker
Page 8: How do I run microservices in production using Docker
Page 9: How do I run microservices in production using Docker
Page 10: How do I run microservices in production using Docker
Page 11: How do I run microservices in production using Docker

• The services are easy to replace.

• Services are organized around capabilities, e.g., user

interface front-end, recommendation, logistics, billing, etc.

• Services can be implemented using different programming

languages, databases, hardware and software environment,

depending on what fits best.

microservice architecture

$$$$

$$$

$$

$

$

$

Page 12: How do I run microservices in production using Docker

%

$#

$$

%

$#

$$

%

$#

$$

%

$#

$$

Page 13: How do I run microservices in production using Docker
Page 14: How do I run microservices in production using Docker

NOISE

$docker run alpine echo 'hello world’

production

?

$docker-compose up -d

time

skill

s

Page 15: How do I run microservices in production using Docker

&

$

#

#1 the right container image

#2 containers in production

$$

microservice example

Page 16: How do I run microservices in production using Docker

% service

$ containers

server cluster(s)'

image$#

$$

= code

= docker file

= docker engine

= platform

$

build

ship

deploy

Page 17: How do I run microservices in production using Docker

%

$#

% %test test

$# $#dev machine

continuous

integration

continuous

deployment

( (

))

code *

service *

Page 18: How do I run microservices in production using Docker

% $

$

api

%

$# $#

workermessage

queue%frontend

request work

status update

microservice example

Page 19: How do I run microservices in production using Docker

% $

$

%

$# $#I can bake 1 donut in x seconds.

message queue%

I want 5 donuts

request 5 donuts

donuts are baking donuts are ready

I know how to receive orders and give orders to baking minions.

Page 20: How do I run microservices in production using Docker

https://github.com/cloud66-samples/webinar_codefresh

+

$$$

Page 21: How do I run microservices in production using Docker
Page 22: How do I run microservices in production using Docker
Page 23: How do I run microservices in production using Docker
Page 24: How do I run microservices in production using Docker
Page 25: How do I run microservices in production using Docker
Page 26: How do I run microservices in production using Docker
Page 27: How do I run microservices in production using Docker
Page 28: How do I run microservices in production using Docker

%

$#

$$

%

$#

$$

%

$#

$$

%

$#

$$

Page 29: How do I run microservices in production using Docker
Page 30: How do I run microservices in production using Docker
Page 31: How do I run microservices in production using Docker
Page 32: How do I run microservices in production using Docker
Page 33: How do I run microservices in production using Docker
Page 34: How do I run microservices in production using Docker
Page 35: How do I run microservices in production using Docker
Page 36: How do I run microservices in production using Docker
Page 37: How do I run microservices in production using Docker
Page 38: How do I run microservices in production using Docker

%

$#

$$

%

$#

$$

%

$#

$$

%

$#

$$

Page 39: How do I run microservices in production using Docker

%

$#

$$

isolated test

Page 40: How do I run microservices in production using Docker

%

$#

$$

isolated test

(API)

Page 41: How do I run microservices in production using Docker
Page 42: How do I run microservices in production using Docker
Page 43: How do I run microservices in production using Docker

%

$#

$$

isolated test

(WORKER)

Page 44: How do I run microservices in production using Docker
Page 45: How do I run microservices in production using Docker
Page 46: How do I run microservices in production using Docker

%

$#

$$

integration test + development

%

$#

$$

%

$#

$$

%

$#

$$

Page 47: How do I run microservices in production using Docker
Page 48: How do I run microservices in production using Docker

&containerization

,

-

./

the containerization machine

$$$

Page 49: How do I run microservices in production using Docker

,you can’t polish a turd

&

$

containerization

-

.0

$$$ =

Page 50: How do I run microservices in production using Docker

$#

“The right image should be the same in all your environments.”

Page 51: How do I run microservices in production using Docker

$#

“The right tests should be the same in all your environments.”

Page 52: How do I run microservices in production using Docker

$#

“I didn't have time to create a slim image, so I created a fat one instead.”

Page 53: How do I run microservices in production using Docker

$#

“The right image needs at least 5 kisses” kiss = keep an image s…, smart ass

slim secure speedy stable set

Page 54: How do I run microservices in production using Docker

SLIM Start with the smallest minimal image you can find and trust. Remove compile time dependencies. Remove packages you don’t need. Squash layers to reduce size. Run stats for the image. habitus.io blog.cloud66.com

$#

Page 55: How do I run microservices in production using Docker
Page 56: How do I run microservices in production using Docker
Page 57: How do I run microservices in production using Docker

SLIM SECURE SPEEDY STABLE

SET

$#

Page 58: How do I run microservices in production using Docker

SECURE Remove all the secrets. Patch to the latest security updates. Run the image with the right UID. Test the image. https://github.com/docker/docker-bench-security

$#

Page 59: How do I run microservices in production using Docker

SMALL SECURE SPEEDY STABLE

SET

$#

Page 60: How do I run microservices in production using Docker

SPEEDY Optimize code. Memory and cpu usage. One process. Load testing.

$#

Page 61: How do I run microservices in production using Docker

SLIM SECURE SPEEDY STABLE

SET

$#

Page 62: How do I run microservices in production using Docker

STABLE Lock the image version. Lock the runtime version(s). Tag your image. Proper logging.

$#

Page 63: How do I run microservices in production using Docker

SLIM SECURE SPEEDY STABLE

SET

$#

Page 64: How do I run microservices in production using Docker

SET Use volumes wisely, use external services for persistency, don’t abuse host system. Loosely coupled. Remove things which are hard to maintain in production.

$#

Page 65: How do I run microservices in production using Docker
Page 66: How do I run microservices in production using Docker

Reality Check!

Page 67: How do I run microservices in production using Docker

%

$#

$ 2

monolith containerization ± 70 % (multi tenant)

monolith 1x

monolith image FAT

Page 68: How do I run microservices in production using Docker

%

$#

$

2

API first containerization ± 20%

$#

$api 1x

frontend 1x

image frontend FAT

image api FAT

Page 69: How do I run microservices in production using Docker

%

$#

$

2

splitting monolith containerization ± 6%

$#api 6x

frontend 1x $#

$

workers 10x

$$$$$$$$$

image frontend FAT

image api THIN

image workers THIN

$$$$$$

Page 70: How do I run microservices in production using Docker

%

$#

32

$#A 6x

B 12x $#

$

C 10x

$$$$$$$$$

image B THIN

image A THIN

image C THIN

$$$$$$

microservice architecture ± 4%

$$$$$$$

$$$$$

message queue

Page 71: How do I run microservices in production using Docker

$#

microservice microimage microplatform?

law of conservation of energy?

Page 72: How do I run microservices in production using Docker

LIFE CYCLE

$#ORCHESTRATION DISCOVERY

SECURITY

SCALING

DATA MANAGEMENT

MONITORING

SCHEDULING

Page 73: How do I run microservices in production using Docker
Page 74: How do I run microservices in production using Docker

Choose your platform wisely.

Page 75: How do I run microservices in production using Docker

LIFE CYCLE

$#ORCHESTRATION DISCOVERY

SECURITY

SCALING

DATA MANAGEMENT

MONITORING

SCHEDULING

Page 76: How do I run microservices in production using Docker

LIFE CYCLE

$#ORCHESTRATION DISCOVERY

SECURITY

SCALING

DATA MANAGEMENT

MONITORING

SCHEDULING

Page 77: How do I run microservices in production using Docker

LIFECYCLE Have an image guideline. Create a workflow using the same image in all the software cycle stages. From design to production mimic the environment. Test heavily.

42

Page 78: How do I run microservices in production using Docker

LIFE CYCLE

$#ORCHESTRATION DISCOVERY

SECURITY

SCALING

DATA MANAGEMENT

MONITORING

SCHEDULING

Page 79: How do I run microservices in production using Docker

ORCHESTRATION Provisioning nodes. Networking. Isolation of services. Self healing. iOi = Infrastructure on Infrastructure.

45

Page 80: How do I run microservices in production using Docker

LIFE CYCLE

$#ORCHESTRATION DISCOVERY

SECURITY

SCALING

DATA MANAGEMENT

MONITORING

SCHEDULING

Page 81: How do I run microservices in production using Docker

DISCOVERY Find your services and datasources with minimal code change. Versioning of running services. Automagically update discovery when services come and go.

46

Page 82: How do I run microservices in production using Docker

LIFE CYCLE

$#ORCHESTRATION DISCOVERY

SECURITY

SCALING

DATA MANAGEMENT

MONITORING

SCHEDULING

Page 83: How do I run microservices in production using Docker

SCALING/SCHEDULING Scale your service (= more running containers). Scale your nodes. Scale your on/off jobs. Failover groups. Hybrid infrastructure. Load balancing.

47

Page 84: How do I run microservices in production using Docker

LIFE CYCLE

$#ORCHESTRATION DISCOVERY

SECURITY

SCALING

DATA MANAGEMENT

MONITORING

SCHEDULING

Page 85: How do I run microservices in production using Docker

DATA MANAGEMENT Backup and restores. Clustering. Verify your backups.

4

Page 86: How do I run microservices in production using Docker

LIFE CYCLE

$#ORCHESTRATION DISCOVERY

SECURITY

SCALING

DATA MANAGEMENT

MONITORING

SCHEDULING

Page 87: How do I run microservices in production using Docker

MONITORING Get all the statistics of resources (mem/load/net/res) used. Aggregating of logs. Key debugging ingredient.

48

Page 88: How do I run microservices in production using Docker

LIFE CYCLE

$#ORCHESTRATION DISCOVERY

SECURITY

SCALING

DATA MANAGEMENT

MONITORING

SCHEDULING

Page 89: How do I run microservices in production using Docker

SECURITY Node and Engine level. Intrusion detection and prevention systems. DoS protection. Firewall. Segregate container groups Verification of images.

44

Page 90: How do I run microservices in production using Docker

Choose your platform wisely.

Page 91: How do I run microservices in production using Docker

When you get DevOps, Testing, Microservices architecture right and creating the right minimal lovable Image and having the right platform to run containers. Happy Camper.

#

Page 92: How do I run microservices in production using Docker

THANK YOU www.cloud66.com (free docker in production platform trial) www.codefresh.com www.habitus.io (open source docker build flow tool) startwithdocker.com (easy starter for docker) https://github.com/cloud66-samples/webinar_codefresh

```

$#

Daniël van Gils Developer Advocate

@foldingbeauty [email protected]

www.cloud66.com

!

"