Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Production deployment of the Docker container w...

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
Tweet

More Decks by Tatsuro Mitsuno

Other Decks in Technology

Transcript

  1. 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
  2. OUR COMPANY ▸ Company: 
 VASILY, Inc. / גࣜձࣾVASILY ▸

    Address:
 ౦ژ౎඼઒۠੢ޒ൓ా2-23-5 δχΞεϏϧ 6F ▸ Employee:
 35 ▸ Engineer:
 16
  3. ▸ over 2.5M users ▸ over 1.6 M fashion items

    ▸ crawl from hundreds of EC sites Θͨ͠ͷʮ޷͖ʯ͕͜͜ʹ͋Δ
  4. TOC ▸ Introduction ▸ VASILY Crawler Overview ▸ Crawler Application

    ▸ Crawler Infrastructure ▸ Container Production Deployment ▸ deploy application ▸ update container image
  5. CONTAINERIZED APPLICATION Containerized Application is ... ▸ Cool ▸ Modern

    ▸ Difficult ▸ The most difficult point I think is production deployment. but ...
  6. </> CONTAINERIZED APPLICATION in Development in Production run simple &

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

    easy complexity & difficulty EC2 INSTANCE EC2 INSTANCE CI/CD service container image registory ? ? ? ? ? Today's theme
  8. 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
  9. 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/
  10. 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" } } } }
  11. TOC ▸ Introduction ▸ VASILY Crawler Overview ▸ Crawler Application

    ▸ Crawler Infrastructure ▸ Container Production Deployment ▸ deploy application ▸ update container image
  12. 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
  13. 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
  14. </> </> DEPLOY APPLICATION deployment strategy Icons made by Roundicons

    from www.flaticon.com is licensed by Creative Commons BY 3.0 + adoption
  15. 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
  16. 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 } ] } }
  17. 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 ‘
  18. 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
  19. 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
  20. UPDATE CONTAINER IMAGE repository design ▸ application repository ▸ iqon_crawler

    EC2 INSTANCE ▸ infrastructure repository ▸ iqon_infra ▸ Chef / Packer / Vagrant / DNS configure / ... APPLICATION APPLICATION APPLICATION
  21. 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
  22. ▸ 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
  23. 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
  24. 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
  25. 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
  26. 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 ▸ ...