Slide 1

Slide 1 text

Production deployment of the Docker container with Marathon ʲώΧˑϥϘʳDockerΛར༻ͨ͠։ൃࣄྫ 2017/04/13 Thu. Tatsuro Mitsuno VASILY, inc.

Slide 2

Slide 2 text

WHO AM I @kotatsu360 ▸ Tatsuro Mitsuno / ޫ໺ ୡ࿕ ▸ 2012/04 Yahoo Japan Corporation ▸ 2016/04 VASILY, Inc ▸ Infrastructure Engineer ▸ Twitter GitHub Qiita: @kotatsu360 Icon illustrated by YOSHI https://ja-jp.facebook.com/yoshi.yone.7

Slide 3

Slide 3 text

OUR COMPANY ▸ Company: 
 VASILY, Inc. / גࣜձࣾVASILY ▸ Address:
 ౦ژ౎඼઒۠੢ޒ൓ా2-23-5 δχΞεϏϧ 6F ▸ Employee:
 35 ▸ Engineer:
 16

Slide 4

Slide 4 text

▸ over 2.5M users ▸ over 1.6 M fashion items ▸ crawl from hundreds of EC sites Θͨ͠ͷʮ޷͖ʯ͕͜͜ʹ͋Δ

Slide 5

Slide 5 text

TOC ▸ Introduction ▸ VASILY Crawler Overview ▸ Crawler Application ▸ Crawler Infrastructure ▸ Container Production Deployment ▸ deploy application ▸ update container image

Slide 6

Slide 6 text

Containerized Application Introduction

Slide 7

Slide 7 text

CONTAINERIZED APPLICATION Containerized Application is ... ▸ Cool ▸ Modern ▸ Difficult ▸ The most difficult point I think is production deployment. but ...

Slide 8

Slide 8 text

> CONTAINERIZED APPLICATION in Development in Production run simple & easy complexity & difficulty EC2 INSTANCE EC2 INSTANCE CI/CD service container image registory ? ? ? ? ?

Slide 9

Slide 9 text

> CONTAINERIZED APPLICATION in Development in Production run simple & easy complexity & difficulty EC2 INSTANCE EC2 INSTANCE CI/CD service container image registory ? ? ? ? ? Today's theme

Slide 10

Slide 10 text

Overview VASILY Crawler

Slide 11

Slide 11 text

OVERVIEW Crawler Application Ruby 2.3.3 Amazon Simple Queue Service (SQS)

Slide 12

Slide 12 text

OVERVIEW Crawler Application ▸ Containerized Application ▸ Parallel Distributed Processing Application ( called `worker` ) XPSLFS % XPSLFS % XPSLFS $ XPSLFS $ XPSLFS # XPSLFS # XPSLFS " XPSLFS " Independent
 from each other via SQS 1 worker, 1 container

Slide 13

Slide 13 text

OVERVIEW Crawler Infrastructure

Slide 14

Slide 14 text

OVERVIEW Apache MESOS ▸ A distributed systems kernel ▸ Apache Mesos abstracts CPU, memory, storage, and other compute resources away from machines. ▸ Native support for launching containers with Docker and AppC images. ▸ Mesos Frameworks ▸ Hadoop / Cassandra / Marathon / ... ref. https://mesosphere.com/why-mesos/

Slide 15

Slide 15 text

OVERVIEW Marathon ▸ A container orchestration platform for Mesos and DC/OS ▸ Long Running Services ▸ The mesos task is executed only once ▸ Marathon keeps task state ▸ JSON format ref. https://github.com/mesosphere/marathon-ui { "parse": { "id": "/iqon/crawler/parse", "container": { "type": "DOCKER", "docker": { "image": "xxxxxx" } } } }

Slide 16

Slide 16 text

OVERVIEW Crawler Infrastructure AWS EC2 Spot Fleet with AutoScaling

Slide 17

Slide 17 text

OVERVIEW Crawler Infrastructure Today's theme: production deployment AWS EC2 Spot Fleet with AutoScaling

Slide 18

Slide 18 text

TOC ▸ Introduction ▸ VASILY Crawler Overview ▸ Crawler Application ▸ Crawler Infrastructure ▸ Container Production Deployment ▸ deploy application ▸ update container image

Slide 19

Slide 19 text

Deploy Application Container Production Deployment

Slide 20

Slide 20 text

DEPLOY APPLICATION deployment strategy: Is container image containg source code? > > + a container image NOT containing source code a container image containing source code Icons made by Roundicons from www.flaticon.com is licensed by Creative Commons BY 3.0

Slide 21

Slide 21 text

DEPLOY APPLICATION deployment strategy: Is source code contained container image ? ▸ A container image containing source code is very simple and comfortable. ▸ but ... ▸ A large number of tags are registered in the container registry ▸ Can not separate application and environment ▸ Container image caching does not work at deployment time

Slide 22

Slide 22 text

> > DEPLOY APPLICATION deployment strategy Icons made by Roundicons from www.flaticon.com is licensed by Creative Commons BY 3.0 + adoption

Slide 23

Slide 23 text

DEPLOY APPLICATION deployment strategy > A nice mechanism to work when deploying Marathon fetch = Icons made by Roundicons from www.flaticon.com is licensed by Creative Commons BY 3.0

Slide 24

Slide 24 text

DEPLOY APPLICATION Marathon fetch ▸ The list of URIs to fetch before the task starts. ▸ fetch (HTTP, HTTPS, FTP, FTPS, ...) ▸ [option] extract ▸ [option] executable (chmod +x) ▸ [option] cache ▸ Marathon fetch is build on the mechanism of Apache Mesos fetcher. { "parse": { "id": "/iqon/crawler/parse", "container": { "type": "DOCKER", "docker": { "image": "xxxxxx" }, "volumes": [ { "containerPath": "/var/app", "hostPath": "./iqon_crawler" } ] }, "fetch": [ { "uri": "https:// xxxxx /iqon_crawler.tar.gz", "executable": false, "extract": true, "cache": false } ] } }

Slide 25

Slide 25 text

DEPLOY APPLICATION Marathon fetch Mesos Task Sandbox 4. docker run --volume "/ path / to / sandbox / root / iqon_crawler : /var/app" ... 1. fetch: https:// xxxxx /iqon_crawler.tar.gz 2. iqon_crawler.tar.gz 3. tar xzf iqon_cralwer.tar.gz ‘

Slide 26

Slide 26 text

DEPLOY APPLICATION Deploy Application AWS EC2 Spot Fleet with AutoScaling Today's theme: production deployment

Slide 27

Slide 27 text

4. pull
 container image DEPLOY APPLICATION Deploy Application AWS EC2 Spot Fleet 1. copy
 source code 3. fetch
 source code 5. mount
 & run Amazon S3 quay.io (container registory service) 2. http request

Slide 28

Slide 28 text

Update Container Image Container Production Deployment

Slide 29

Slide 29 text

UPDATE CONTAINER IMAGE repository design: Is the Dockerfile placed in the same repository as the application? $ tree -L 1 iqon_crawler iqon_crawler/ !"" Dockerfile !"" Gemfile !"" Gemfile.lock !"" README.md !"" lib/ ... $ tree -L 1 iqon_crawler iqon_crawler/ !"" Gemfile !"" Gemfile.lock !"" README.md !"" lib/ ... $ tree -L 2 iqon_infra/ iqon_infra/ !"" iqon_crawler/ # $"" Dockerfile !"" README.md ... the application repository NOT containing Dockerfile the application repository containing Dockerfile

Slide 30

Slide 30 text

UPDATE CONTAINER IMAGE repository design ▸ application repository ▸ iqon_crawler EC2 INSTANCE ▸ infrastructure repository ▸ iqon_infra ▸ Chef / Packer / Vagrant / DNS configure / ... APPLICATION APPLICATION APPLICATION

Slide 31

Slide 31 text

UPDATE CONTAINER IMAGE repository design ▸ application repository ▸ iqon_crawler EC2 INSTANCE ▸ infrastructure repository ▸ iqon_infra ▸ Chef / Packer / Vagrant / DNS configure / ... ʁ Dockerfile ʁ APPLICATION APPLICATION APPLICATION DOCKER CONTAINER DOCKER CONTAINER DOCKER CONTAINER

Slide 32

Slide 32 text

▸ Easy unified management ▸ Easy updating of application circumstances ▸ Accelerate deployment (described later) UPDATE CONTAINER IMAGE Merit of containing Dockerfile Merit of not containing Dockerfile Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY update application update Dockerfile update application update Dockerfile

Slide 33

Slide 33 text

UPDATE CONTAINER IMAGE VASILY Repositories ▸ application repository ▸ iqon_crawler EC2 INSTANCE ▸ infrastructure repository ▸ iqon_infra ▸ Chef / Packer / Vagrant / DNS configure / ... Dockerfile APPLICATION APPLICATION APPLICATION DOCKER CONTAINER DOCKER CONTAINER DOCKER CONTAINER ʁ adoption

Slide 34

Slide 34 text

UPDATE CONTAINER IMAGE update container image branch: master branch: dockerbuild 1. ... 2. COPY Gemfile / Gemfile.lock 3. RUN apk add ... && bundle install 4. ... docker build docker push Bundle install is unnecessary at the time of deployment

Slide 35

Slide 35 text

Conclusion

Slide 36

Slide 36 text

CONCLUSION Production deployment of the Docker container with Marathon ▸ VASILY is operating a containerized crawler system ▸ The container image does not contain the source code and it is mounted at deployment time ▸ Dockerfile and application are located in the same repository. ▸ As the application is updated, the container image is appropriately updated

Slide 37

Slide 37 text

CONCLUSION Production deployment of the Docker container with Marathon ▸ If you are interested, please also read this article ▸ Docker / Apache Mesos / Marathon ʹΑΔ3ഒ଎͍IQONΫϩʔϥʔͷߏங
 http://bit.ly/2nD7qxG ▸ Reason for containerization ▸ Architecture ▸ Operational device ▸ ...

Slide 38

Slide 38 text

We’re Hiring!