Stuff I do Follow me! https://pasztor.at @janoszen About this - - PowerPoint PPT Presentation

stuff i do
SMART_READER_LITE
LIVE PREVIEW

Stuff I do Follow me! https://pasztor.at @janoszen About this - - PowerPoint PPT Presentation

Stuff I do Follow me! https://pasztor.at @janoszen About this talk 1. Maintaining your Build Stack 2. Orchestrating your Cluster 3. Pitfalls and Recommendations About this talk 1. Maintaining your Build Stack 2. Orchestrating your Cluster


slide-1
SLIDE 1
slide-2
SLIDE 2

Stuff I do

slide-3
SLIDE 3

Follow me!

https://pasztor.at @janoszen

slide-4
SLIDE 4

About this talk

  • 1. Maintaining your Build Stack
  • 2. Orchestrating your Cluster
  • 3. Pitfalls and Recommendations
slide-5
SLIDE 5

About this talk

  • 1. Maintaining your Build Stack
  • 2. Orchestrating your Cluster
  • 3. Pitfalls and Recommendations
slide-6
SLIDE 6

About this talk

  • 1. Maintaining your Build Stack
  • 2. Orchestrating your Cluster
  • 3. Pitfalls and Recommendations
slide-7
SLIDE 7

Maintaining your Build Stack

How Docker Images are Built

slide-8
SLIDE 8

Maintaining your Build Stack

FROM ubuntu:16.04

How Docker Images are Built

slide-9
SLIDE 9

Maintaining your Build Stack

FROM ubuntu:16.04 RUN apt-get install...

How Docker Images are Built

slide-10
SLIDE 10

Maintaining your Build Stack

FROM ubuntu:16.04 RUN apt-get install...

How Docker Images are Built

COPY files/etc /etc

slide-11
SLIDE 11

Maintaining your Build Stack

FROM ubuntu:16.04 COPY files/etc /etc RUN apt-get install... COPY init.sh /init.sh

How Docker Images are Built

slide-12
SLIDE 12

Maintaining your Build Stack

FROM ubuntu:16.04 COPY files/etc /etc RUN apt-get install... COPY init.sh /init.sh CMD /init.sh

How Docker Images are Built

slide-13
SLIDE 13

Maintaining your Build Stack

FROM ubuntu:16.04 COPY files/etc /etc RUN apt-get install... COPY init.sh /init.sh CMD /init.sh

How Docker Images are Built

e87eea024487 c90c59c78830 31c6577f6847 54511612f1c4 9e54da99b80c

slide-14
SLIDE 14

Maintaining your Build Stack

FROM ubuntu:16.04 COPY files/etc /etc RUN apt-get install... COPY init.sh /init.sh CMD /init.sh

How Docker Images are Built

e87eea024487 c90c59c78830 31c6577f6847 54511612f1c4 9e54da99b80c latest

slide-15
SLIDE 15

Maintaining your Build Stack

Your Laptop Server

slide-16
SLIDE 16

Maintaining your Build Stack

Your Laptop Server Docker Image

slide-17
SLIDE 17

Maintaining your Build Stack

Your Laptop Server Docker Image Docker Image

slide-18
SLIDE 18

Maintaining your Build Stack

Your Laptop Server Docker Image Docker Image

slide-19
SLIDE 19

Maintaining your Build Stack

Your Laptop Server Docker Image Registry

slide-20
SLIDE 20

Maintaining your Build Stack

Your Laptop Server Docker Image Registry docker push Docker Image

slide-21
SLIDE 21

Maintaining your Build Stack

Your Laptop Server Docker Image Registry Docker Image Docker Image

slide-22
SLIDE 22

Maintaining your Build Stack

Your Laptop Server Docker Image Registry Docker Image Docker Image Docker Container

slide-23
SLIDE 23

Follow me!

Problems:

slide-24
SLIDE 24

Follow me!

Problems:

High Bandwidth Usage

slide-25
SLIDE 25

Follow me!

Problems:

High Bandwidth Usage Different Hashes on Different Machines

slide-26
SLIDE 26

Maintaining your Build Stack

Your Laptop Server Dockerfile Registry Git Server CI Server

slide-27
SLIDE 27

Maintaining your Build Stack

Your Laptop Server Dockerfile Registry Git Server CI Server Dockerfile

slide-28
SLIDE 28

Maintaining your Build Stack

Your Laptop Server Dockerfile Registry Git Server CI Server Dockerfile Dockerfile

slide-29
SLIDE 29

Maintaining your Build Stack

Your Laptop Server Dockerfile Registry Git Server CI Server Dockerfile Dockerfile Docker Image

slide-30
SLIDE 30

Maintaining your Build Stack

Your Laptop Server Dockerfile Registry Git Server CI Server Dockerfile Dockerfile Docker Image Docker Image

slide-31
SLIDE 31

Maintaining your Build Stack

Your Laptop Server Dockerfile Registry Git Server CI Server Dockerfile Dockerfile Docker Image Docker Image Docker Image

slide-32
SLIDE 32

Maintaining your Build Stack

Your Laptop Server Dockerfile Registry Git Server CI Server Dockerfile Dockerfile Docker Image Docker Image Docker Image Docker Container

slide-33
SLIDE 33

Maintaining your Build Stack

CI server Docker Repository YES YES YES YES YES YES YES YES YES

slide-34
SLIDE 34

Orchestrating your Cluster

How do you run a Docker image?

slide-35
SLIDE 35

Orchestrating your Cluster

ssh youruser@example.com "docker run yourcontainer"

How do you run a Docker image?

slide-36
SLIDE 36

Orchestrating your Cluster

ssh youruser@example.com "docker run yourcontainer"

How do you run a Docker image?

slide-37
SLIDE 37

Orchestrating your Cluster

Orchestration tools

slide-38
SLIDE 38

Orchestrating your Cluster

Orchestration tools

Where is my service?

slide-39
SLIDE 39

Orchestrating your Cluster

Orchestration tools

Where is my service? Rolling updates

slide-40
SLIDE 40

Orchestrating your Cluster

Orchestration tools

Where is my service? Rolling updates Scaling

slide-41
SLIDE 41

Orchestrating your Cluster

Orchestration tools

Where is my service? Rolling updates Scaling Virtual networks

slide-42
SLIDE 42

Orchestrating your Cluster

Orchestration tools

Where is my service? Rolling updates Scaling Virtual networks ...

slide-43
SLIDE 43

Orchestrating your Cluster

Orchestration tools

AWS EC2 Container Service Docker Swarm Kubernetes ...

slide-44
SLIDE 44

Orchestrating your Cluster

EC2 Container Service

slide-45
SLIDE 45

Orchestrating your Cluster

EC2 Container Service

+ Integrated with AWS

slide-46
SLIDE 46

Orchestrating your Cluster

EC2 Container Service

+ Integrated with AWS + Autoscaling (limited)

slide-47
SLIDE 47

Orchestrating your Cluster

EC2 Container Service

+ Integrated with AWS + Autoscaling (limited) + Integrated registry

slide-48
SLIDE 48

Orchestrating your Cluster

EC2 Container Service

+ Integrated with AWS + Autoscaling (limited) + Integrated registry

  • Using the ELB is a must
slide-49
SLIDE 49

Orchestrating your Cluster

EC2 Container Service

+ Integrated with AWS + Autoscaling (limited) + Integrated registry

  • Using the ELB is a must
  • No built-in DNS server
slide-50
SLIDE 50

Orchestrating your Cluster

EC2 Container Service

+ Integrated with AWS + Autoscaling (limited) + Integrated registry

  • Using the ELB is a must
  • No built-in DNS server
  • Slow rollout
slide-51
SLIDE 51

Orchestrating your Cluster

EC2 Container Service

+ Integrated with AWS + Autoscaling (limited) + Integrated registry

  • Using the ELB is a must
  • No built-in DNS server
  • Slow rollout
  • No overlay network
slide-52
SLIDE 52

Orchestrating your Cluster

EC2 Container Service

+ Integrated with AWS + Autoscaling (limited) + Integrated registry

  • Using the ELB is a must
  • No built-in DNS server
  • Slow rollout
  • No overlay network
  • Outdated
slide-53
SLIDE 53

Orchestrating your Cluster

Docker Swarm

slide-54
SLIDE 54

Orchestrating your Cluster

Docker Swarm

+ (Very) Simple

slide-55
SLIDE 55

Orchestrating your Cluster

Docker Swarm

+ (Very) Simple + Overlay Networks

slide-56
SLIDE 56

Orchestrating your Cluster

Docker Swarm

+ (Very) Simple + Overlay Networks + Built-in DNS server and LB

slide-57
SLIDE 57

Orchestrating your Cluster

Docker Swarm

+ (Very) Simple + Overlay Networks + Built-in DNS server and LB + Fast rollout

slide-58
SLIDE 58

Orchestrating your Cluster

Docker Swarm

+ (Very) Simple + Overlay Networks + Built-in DNS server and LB + Fast rollout

  • Very young (YMMV)
slide-59
SLIDE 59

Orchestrating your Cluster

Docker Swarm

+ (Very) Simple + Overlay Networks + Built-in DNS server and LB + Fast rollout

  • Very young (YMMV)
  • No Autoscaling
slide-60
SLIDE 60

Orchestrating your Cluster

Docker Swarm

+ (Very) Simple + Overlay Networks + Built-in DNS server and LB + Fast rollout

  • Very young (YMMV)
  • No Autoscaling
  • Monolithic (no plugins)
slide-61
SLIDE 61

Orchestrating your Cluster

Kubernetes

+ Overlay networks

slide-62
SLIDE 62

Orchestrating your Cluster

Kubernetes

+ Overlay networks + Autoscaling

slide-63
SLIDE 63

Orchestrating your Cluster

Kubernetes

+ Overlay networks + Autoscaling + Rack awareness

slide-64
SLIDE 64

Orchestrating your Cluster

Kubernetes

+ Overlay networks + Autoscaling + Rack awareness + Plugins, everywhere

slide-65
SLIDE 65

Orchestrating your Cluster

Kubernetes

+ Overlay networks + Autoscaling + Rack awareness + Plugins, everywhere + Makes you coffee

slide-66
SLIDE 66

Orchestrating your Cluster

Kubernetes

+ Overlay networks + Autoscaling + Rack awareness + Plugins, everywhere + Makes you coffee

  • Complex to set up
slide-67
SLIDE 67

Orchestrating your Cluster

Kubernetes

+ Overlay networks + Autoscaling + Rack awareness + Plugins, everywhere + Makes you coffee

  • Complex to set up
  • Setup scripts and docs are

beta / unstable / outdated

slide-68
SLIDE 68

Pitfalls and Recommendations

Oops...

slide-69
SLIDE 69

Pitfalls and Recommendations

Multiple services in one container?

slide-70
SLIDE 70

Pitfalls and Recommendations

Multiple services in one container? DON’T!

slide-71
SLIDE 71

Pitfalls and Recommendations

supervisord nginx PHP-FPM

slide-72
SLIDE 72

Pitfalls and Recommendations

supervisord nginx PHP-FPM

slide-73
SLIDE 73

Pitfalls and Recommendations

supervisord nginx

slide-74
SLIDE 74

Pitfalls and Recommendations

Sidecar services

slide-75
SLIDE 75

Pitfalls and Recommendations

supervisord PHP-FPM nullmailer

slide-76
SLIDE 76

Pitfalls and Recommendations

supervisord PHP-FPM nullmailer manage-supervisord

slide-77
SLIDE 77

Pitfalls and Recommendations

supervisord PHP-FPM nullmailer manage-supervisord

slide-78
SLIDE 78

Pitfalls and Recommendations

supervisord PHP-FPM manage-supervisord

slide-79
SLIDE 79

Pitfalls and Recommendations

supervisord PHP-FPM manage-supervisord https://github.com/opsbears/docker-supervisord

slide-80
SLIDE 80

Pitfalls and Recommendations

Shell script in CMD?

slide-81
SLIDE 81

Pitfalls and Recommendations

Shell script in CMD? BE CAREFUL!

slide-82
SLIDE 82

Pitfalls and Recommendations

#!/bin/bash # Other stuff here /usr/sbin/nginx -g "daemon off;" exit $?

slide-83
SLIDE 83

Pitfalls and Recommendations

bash -c /init.sh nginx

slide-84
SLIDE 84

Pitfalls and Recommendations

bash -c /init.sh nginx SIGTERM

slide-85
SLIDE 85

Pitfalls and Recommendations

bash -c /init.sh nginx SIGTERM YOLO!

slide-86
SLIDE 86

Pitfalls and Recommendations

bash -c /init.sh nginx SIGKILL!

slide-87
SLIDE 87

Pitfalls and Recommendations

#!/bin/bash # Other stuff here exec /usr/sbin/nginx -g "daemon off;"

slide-88
SLIDE 88

Pitfalls and Recommendations

bash -c /init.sh

slide-89
SLIDE 89

Pitfalls and Recommendations

nginx

slide-90
SLIDE 90

Pitfalls and Recommendations

Don’t update your containers!

slide-91
SLIDE 91

Pitfalls and Recommendations

Shared data?

slide-92
SLIDE 92

Pitfalls and Recommendations

Server Container

slide-93
SLIDE 93

Pitfalls and Recommendations

Server /srv/mysql Container bind mount

slide-94
SLIDE 94

Pitfalls and Recommendations

Server /srv/mysql Server Container

slide-95
SLIDE 95

Pitfalls and Recommendations

Healthchecks?

slide-96
SLIDE 96

Pitfalls and Recommendations

Dockerfile:

HEALTHCHECK \

  • -interval=10s \
  • -timeout=3s \

CMD /usr/local/bin/healthcheck

healthcheck:

#!/bin/bash test $(SCRIPT_NAME=/status SCRIPT_FILENAME=/status REQUEST_METHOD=GET cgi-fcgi -bind

  • connect 127.0.0.1:9000 | grep

pool | cut -d: -f2 | sed 's/ //g') == www || exit 1

slide-97
SLIDE 97

Pitfalls and Recommendations

healthcheck:

#!/bin/bash test $(SCRIPT_NAME=/status SCRIPT_FILENAME=/status REQUEST_METHOD=GET cgi-fcgi -bind -connect 127.0.0.1:9000 | grep pool | cut -d: -f2 | sed 's/ //g') == www || exit 1

slide-98
SLIDE 98

Pitfalls and Recommendations

Docker Swarm:

HEALTHCHECK \

  • -interval=10s \
  • -timeout=3s \

CMD /usr/local/bin/healthcheck

slide-99
SLIDE 99

Pitfalls and Recommendations

Kubernetes:

spec: containers:

  • name: yourpod

livenessProbe: exec: command:

  • /usr/local/bin/healthcheck

initialDelaySeconds: 5 periodSeconds: 5 readinessProbe: ....

slide-100
SLIDE 100

Pitfalls and Recommendations

TEST YO’ CONTAINERS!

slide-101
SLIDE 101

Pitfalls and Recommendations

docker-compose.test.yml

version: '3.2' services: mysql: container_name: mysql build: . ... sut: build: ./test ...

slide-102
SLIDE 102

Pitfalls and Recommendations

DO NOT HARD-CODE CREDENTIALS!

slide-103
SLIDE 103

Pitfalls and Recommendations

VERSION YOUR IMAGES!

slide-104
SLIDE 104

Pitfalls and Recommendations

CAREFUL WITH 3RD PARTY IMAGES!

slide-105
SLIDE 105

Pitfalls and Recommendations

  • psbears/base
  • psbears/supervisord
  • psbears/nullmailer
  • psbears/mysql
  • psbears/nginx
  • psbears/php-fpm
slide-106
SLIDE 106

Pitfalls and Recommendations

REMOVE DEV STUFF!

slide-107
SLIDE 107

That’s all!

Questions?

Many thanks to Bence Sántha, Gábor Vereb, Dávid Papp for their inspiration and feedback.