Share
Embed
Production deployment of the Docker container with Marathon
【ヒカ☆ラボ】Dockerを利用した開発事例~Docker導入から運用まで~
https://atnd.org/events/86945
ref1. Docker / Apache Mesos / Marathon による3倍速いIQONクローラーの構築
http://tech.vasily.jp/entry/iqon-crawler-by-docker-and-mesos-and-marathon
Tatsuro Mitsuno
April 13, 2017
Transcript
38 slides
-
Production deployment of the Docker container with Marathon ʲώΧˑϥϘʳDockerΛར༻ͨ͠։ൃࣄྫ 2017/04/13
Thu. Tatsuro Mitsuno VASILY, inc. -
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 -
OUR COMPANY ▸ Company: VASILY, Inc. / גࣜձࣾVASILY ▸
Address: ౦ژ۠ޒా2-23-5 δχΞεϏϧ 6F ▸ Employee: 35 ▸ Engineer: 16 -
▸ over 2.5M users ▸ over 1.6 M fashion items
▸ crawl from hundreds of EC sites Θͨ͠ͷʮ͖ʯ͕͜͜ʹ͋Δ -
TOC ▸ Introduction ▸ VASILY Crawler Overview ▸ Crawler Application
▸ Crawler Infrastructure ▸ Container Production Deployment ▸ deploy application ▸ update container image -
CONTAINERIZED APPLICATION Containerized Application is ... ▸ Cool ▸ Modern
▸ Difficult ▸ The most difficult point I think is production deployment. but ... -
</> CONTAINERIZED APPLICATION in Development in Production run simple &
easy complexity & difficulty EC2 INSTANCE EC2 INSTANCE CI/CD service container image registory ? ? ? ? ? -
</> CONTAINERIZED APPLICATION in Development in Production run simple &
easy complexity & difficulty EC2 INSTANCE EC2 INSTANCE CI/CD service container image registory ? ? ? ? ? Today's theme -
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 -
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/ -
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" } } } } -
OVERVIEW Crawler Infrastructure Today's theme: production deployment AWS EC2 Spot
Fleet with AutoScaling -
TOC ▸ Introduction ▸ VASILY Crawler Overview ▸ Crawler Application
▸ Crawler Infrastructure ▸ Container Production Deployment ▸ deploy application ▸ update container image -
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 -
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 -
</> </> DEPLOY APPLICATION deployment strategy Icons made by Roundicons
from www.flaticon.com is licensed by Creative Commons BY 3.0 + adoption -
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 -
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 } ] } } -
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 ‘ -
DEPLOY APPLICATION Deploy Application AWS EC2 Spot Fleet with AutoScaling
Today's theme: production deployment -
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 -
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 -
UPDATE CONTAINER IMAGE repository design ▸ application repository ▸ iqon_crawler
EC2 INSTANCE ▸ infrastructure repository ▸ iqon_infra ▸ Chef / Packer / Vagrant / DNS configure / ... APPLICATION APPLICATION APPLICATION -
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 -
▸ 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 -
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 -
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 -
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 -
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 ▸ ...