Top Banner
docker service is the new docker run Getting Started with Docker Clustering Mike Goelzer / [email protected] / @mgoelzer Docker Inc.
34

docker run docker service is the new · Getting Started with Docker Clustering Mike Goelzer / [email protected] / @mgoelzer Docker Inc. docker service is the new docker run docker

May 20, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: docker run docker service is the new · Getting Started with Docker Clustering Mike Goelzer / mgoelzer@docker.com / @mgoelzer Docker Inc. docker service is the new docker run docker

docker service is the new docker runGetting Started with Docker Clustering

Mike Goelzer / [email protected] / @mgoelzerDocker Inc.

Page 2: docker run docker service is the new · Getting Started with Docker Clustering Mike Goelzer / mgoelzer@docker.com / @mgoelzer Docker Inc. docker service is the new docker run docker

docker service is the new docker run

docker run nginx

docker run -p 3375:2375 swarm ; docker run -H :3375 nginx

Swarm Mode in Docker Enginedocker swarm init ;docker service create nginx

2013-14

2014-15

2016

Page 3: docker run docker service is the new · Getting Started with Docker Clustering Mike Goelzer / mgoelzer@docker.com / @mgoelzer Docker Inc. docker service is the new docker run docker

Features Walkthrough

Page 4: docker run docker service is the new · Getting Started with Docker Clustering Mike Goelzer / mgoelzer@docker.com / @mgoelzer Docker Inc. docker service is the new docker run docker

Engine

Swarm Mode

$ docker swarm init

Page 5: docker run docker service is the new · Getting Started with Docker Clustering Mike Goelzer / mgoelzer@docker.com / @mgoelzer Docker Inc. docker service is the new docker run docker

Engine

Swarm Mode

$ docker swarm init

$ docker swarm join <IP of manager>:2377

Engine

Page 6: docker run docker service is the new · Getting Started with Docker Clustering Mike Goelzer / mgoelzer@docker.com / @mgoelzer Docker Inc. docker service is the new docker run docker

Engine

Engine

Engine

EngineEngine Engine

Swarm Mode

$ docker swarm init

$ docker swarm join <IP of manager>:2377

Page 7: docker run docker service is the new · Getting Started with Docker Clustering Mike Goelzer / mgoelzer@docker.com / @mgoelzer Docker Inc. docker service is the new docker run docker

Engine

Engine

Engine

EngineEngine Engine

Services

$ docker service create --replicas 3 --name frontend --network mynet

-p 8080:80 frontend:latest

mynet

Page 8: docker run docker service is the new · Getting Started with Docker Clustering Mike Goelzer / mgoelzer@docker.com / @mgoelzer Docker Inc. docker service is the new docker run docker

Engine

Engine

Engine

EngineEngine Engine

Services

$ docker service create --replicas 3 --name frontend --network mynet

-p 8080:80 frontend:latest

$ docker service create --name redis --network mynet redis:latest

mynet

Page 9: docker run docker service is the new · Getting Started with Docker Clustering Mike Goelzer / mgoelzer@docker.com / @mgoelzer Docker Inc. docker service is the new docker run docker

Engine

Engine

Engine

EngineEngine Engine

Node Failure

$ docker service create --replicas 3 --name frontend --network mynet

-p 8080:80 frontend:latest

$ docker service create --name redis --network mynet redis:latest

mynet

Page 10: docker run docker service is the new · Getting Started with Docker Clustering Mike Goelzer / mgoelzer@docker.com / @mgoelzer Docker Inc. docker service is the new docker run docker

Engine

Engine

Engine

EngineEngine Engine

Node Failure

$ docker service create --replicas 3 --name frontend --network mynet

-p 8080:80 frontend:latest

$ docker service create --name redis --network mynet redis:latest

mynet

Page 11: docker run docker service is the new · Getting Started with Docker Clustering Mike Goelzer / mgoelzer@docker.com / @mgoelzer Docker Inc. docker service is the new docker run docker

Engine

Engine

Engine

EngineEngine

Desired State ≠ Actual State

$ docker service create --replicas 3 --name frontend --network mynet

-p 8080:80 frontend:latest

$ docker service create --name redis --network mynet redis:latest

mynet

Page 12: docker run docker service is the new · Getting Started with Docker Clustering Mike Goelzer / mgoelzer@docker.com / @mgoelzer Docker Inc. docker service is the new docker run docker

Engine

Engine

Engine

EngineEngine

Converge Back to Desired State

$ docker service create --replicas 3 --name frontend --network mynet

-p 8080:80 frontend:latest

$ docker service create --name redis --network mynet redis:latest

mynet

Page 13: docker run docker service is the new · Getting Started with Docker Clustering Mike Goelzer / mgoelzer@docker.com / @mgoelzer Docker Inc. docker service is the new docker run docker

Engine

Engine

Engine

EngineEngine

Scaling

$ docker service update --replicas 6 frontend

mynet

Page 14: docker run docker service is the new · Getting Started with Docker Clustering Mike Goelzer / mgoelzer@docker.com / @mgoelzer Docker Inc. docker service is the new docker run docker

Engine

Engine

Engine

EngineEngine

Scaling

$ docker service update --replicas 10 frontend

mynet

Page 15: docker run docker service is the new · Getting Started with Docker Clustering Mike Goelzer / mgoelzer@docker.com / @mgoelzer Docker Inc. docker service is the new docker run docker

Engine

Engine

Engine

EngineEngine

Global Services

$ docker service create --mode=global --name prometheus prom/prometheus

mynet

Page 16: docker run docker service is the new · Getting Started with Docker Clustering Mike Goelzer / mgoelzer@docker.com / @mgoelzer Docker Inc. docker service is the new docker run docker

Engine

Engine

Engine

EngineEngine

Constraints

Engine

docker daemon --label com.example.storage="ssd"

docker daemon --label com.example.storage="ssd"

Page 17: docker run docker service is the new · Getting Started with Docker Clustering Mike Goelzer / mgoelzer@docker.com / @mgoelzer Docker Inc. docker service is the new docker run docker

Engine

Engine

Engine

EngineEngine

Constraints

$ docker service create --replicas 3 --name frontend --network mynet -p 8080:80 --constraint engine.labels.com.example.storage==ssd frontend:latest

Engine

docker daemon --label com.example.storage="ssd"

docker daemon --label com.example.storage="ssd"

Page 18: docker run docker service is the new · Getting Started with Docker Clustering Mike Goelzer / mgoelzer@docker.com / @mgoelzer Docker Inc. docker service is the new docker run docker

Engine

Engine

Engine

EngineEngine

Constraints

$ docker service create --replicas 3 --name frontend --network mynet -p 8080:80 --constraint engine.labels.com.example.storage==ssd frontend:latest

$ docker service update --replicas 10 frontend

Engine

docker daemon --label com.example.storage="ssd"

docker daemon --label com.example.storage="ssd"

Page 19: docker run docker service is the new · Getting Started with Docker Clustering Mike Goelzer / mgoelzer@docker.com / @mgoelzer Docker Inc. docker service is the new docker run docker

HEALTHCHECK --interval=5m --timeout=3s

--retries 3

CMD curl -f http://localhost/ || exit 1

Check web server every 5 minutes, require < 3 sec latency.>= 3 consecutive failures sets unhealthy state

Coming soon: health checks in official images

Container Health Check in Dockerfile

Page 20: docker run docker service is the new · Getting Started with Docker Clustering Mike Goelzer / mgoelzer@docker.com / @mgoelzer Docker Inc. docker service is the new docker run docker

Routing Mesh• Operator reserves a

swarm-wide ingress port (8080) for myapp

• Every node listens on 8080• Container-aware routing mesh

can transparently reroute traffic from Worker3 to a node that is running container

• Built in load balancing into the Engine

• DNS-based service discovery

:8080

User accesses myapp.com:8080

:8080 :8080

frontend frontend

$ docker service create --replicas 3 --name frontend --network mynet

-p 8080:80 frontend:latest

frontend

Page 21: docker run docker service is the new · Getting Started with Docker Clustering Mike Goelzer / mgoelzer@docker.com / @mgoelzer Docker Inc. docker service is the new docker run docker

Routing Mesh: Published Ports• Operator reserves a

swarm-wide ingress port (8080) for myapp

• Every node listens on 8080• Container-aware routing mesh

can transparently reroute traffic from third node to a node that is running container

• Built in load balancing into the Engine

• DNS-based service discovery

:8080

User accesses myapp.com:8080

:8080 :8080

frontend frontend

$ docker service create --replicas 3 --name frontend --network mynet

-p 8080:80 frontend_image:latest

frontend

Page 22: docker run docker service is the new · Getting Started with Docker Clustering Mike Goelzer / mgoelzer@docker.com / @mgoelzer Docker Inc. docker service is the new docker run docker

Secure by default with end-to-end encryption• Out-of-the-box TLS

encryption and mutual auth

• Automatic cert rotation• External or self-signed

root CA• Cryptographic node

identity

CertificateAuthority

TLS

CertificateAuthority

TLS

CertificateAuthority

TLS

TLS TLSTLS

Page 23: docker run docker service is the new · Getting Started with Docker Clustering Mike Goelzer / mgoelzer@docker.com / @mgoelzer Docker Inc. docker service is the new docker run docker

Scale: 2,000 Nodes and Counting● For now: community testing, crowd-sourced nodes, not funded by

Docker● Credit to: Chanwit Kaewkasi, Suranaree University of

Technology (SUT), Thailand● Results:

○ 2,384 nodes○ 96,287 containers○ Manager CPU/memory ≲15%○ Test stopped because 3rd-party monitoring failed

● https://github.com/swarm2k/swarm2k

@chanwit

Page 24: docker run docker service is the new · Getting Started with Docker Clustering Mike Goelzer / mgoelzer@docker.com / @mgoelzer Docker Inc. docker service is the new docker run docker

Deep Dive: Topology

Page 25: docker run docker service is the new · Getting Started with Docker Clustering Mike Goelzer / mgoelzer@docker.com / @mgoelzer Docker Inc. docker service is the new docker run docker

Node

Node

Node

NodeNode

Node

Topology

Node

Node

Node

Node

Node

Node

Page 26: docker run docker service is the new · Getting Started with Docker Clustering Mike Goelzer / mgoelzer@docker.com / @mgoelzer Docker Inc. docker service is the new docker run docker

Node

Node

Node

NodeNode

Node

Topology: roles

Node

Node

Node

Node

Node

Node

Manager

Worker

Page 27: docker run docker service is the new · Getting Started with Docker Clustering Mike Goelzer / mgoelzer@docker.com / @mgoelzer Docker Inc. docker service is the new docker run docker

Node

Node

Node

NodeNode

Node

Topology: roles

Node

Node

Node

Node

Node

Node

Manager

Worker

● Each Node has a role● Roles are dynamic● Programmable Topology

Page 28: docker run docker service is the new · Getting Started with Docker Clustering Mike Goelzer / mgoelzer@docker.com / @mgoelzer Docker Inc. docker service is the new docker run docker

Topology: scaling model

Manager Manager Manager

Worker Worker Worker Worker Worker Worker

Page 29: docker run docker service is the new · Getting Started with Docker Clustering Mike Goelzer / mgoelzer@docker.com / @mgoelzer Docker Inc. docker service is the new docker run docker

Topology: High Availability

Manager Manager Manager

Worker Worker Worker Worker Worker Worker

Leader FollowerFollower

Page 30: docker run docker service is the new · Getting Started with Docker Clustering Mike Goelzer / mgoelzer@docker.com / @mgoelzer Docker Inc. docker service is the new docker run docker

Topology: High Availability

Manager Manager Manager

Worker Worker Worker Worker Worker Worker

Leader FollowerFollower

Page 31: docker run docker service is the new · Getting Started with Docker Clustering Mike Goelzer / mgoelzer@docker.com / @mgoelzer Docker Inc. docker service is the new docker run docker

Topology: High Availability

Manager Manager Manager

Worker Worker Worker Worker Worker Worker

Follower FollowerLeader

Page 32: docker run docker service is the new · Getting Started with Docker Clustering Mike Goelzer / mgoelzer@docker.com / @mgoelzer Docker Inc. docker service is the new docker run docker

Topology: High Availability

Manager Manager Manager

Worker Worker Worker Worker Worker Worker

Follower FollowerLeader

Page 33: docker run docker service is the new · Getting Started with Docker Clustering Mike Goelzer / mgoelzer@docker.com / @mgoelzer Docker Inc. docker service is the new docker run docker

DEMO