$30 off During Our Annual Pro Sale. View Details »

Production deployment of the Docker container with Marathon

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

    View Slide

  2. 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

    View Slide

  3. OUR COMPANY
    ▸ Company: 

    VASILY, Inc. / גࣜձࣾVASILY
    ▸ Address:

    ౦ژ౎඼઒۠੢ޒ൓ా2-23-5 δχΞεϏϧ 6F
    ▸ Employee:

    35
    ▸ Engineer:

    16

    View Slide

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

    View Slide

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

    View Slide

  6. Containerized Application
    Introduction

    View Slide

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

    View Slide

  8. >
    CONTAINERIZED APPLICATION
    in Development in Production

    run
    simple & easy complexity & difficulty
    EC2
    INSTANCE
    EC2
    INSTANCE
    CI/CD
    service
    container
    image
    registory

    ?
    ?
    ?
    ?
    ?

    View Slide

  9. >
    CONTAINERIZED APPLICATION
    in Development in Production

    run
    simple & easy complexity & difficulty
    EC2
    INSTANCE
    EC2
    INSTANCE
    CI/CD
    service
    container
    image
    registory

    ?
    ?
    ?
    ?
    ?
    Today's theme

    View Slide

  10. Overview
    VASILY Crawler

    View Slide

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

    View Slide

  12. 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

    View Slide

  13. OVERVIEW
    Crawler Infrastructure

    View Slide

  14. 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/

    View Slide

  15. 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"
    }
    }
    }
    }

    View Slide

  16. OVERVIEW
    Crawler Infrastructure
    AWS EC2 Spot Fleet
    with AutoScaling

    View Slide

  17. OVERVIEW
    Crawler Infrastructure

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

    View Slide

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

    View Slide

  19. Deploy Application
    Container Production Deployment

    View Slide

  20. 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

    View Slide

  21. 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

    View Slide

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

    View Slide

  23. 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

    View Slide

  24. 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
    }
    ]
    }
    }

    View Slide

  25. 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

    View Slide

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

    View Slide

  27. 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

    View Slide

  28. Update Container Image
    Container Production Deployment

    View Slide

  29. 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

    View Slide

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

    View Slide

  31. 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

    View Slide

  32. ▸ 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

    View Slide

  33. 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

    View Slide

  34. 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

    View Slide

  35. Conclusion

    View Slide

  36. 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

    View Slide

  37. 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
    ▸ ...

    View Slide

  38. We’re Hiring!

    View Slide