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

Containers @ Google App Engine

Minku Lee
December 22, 2017

Containers @ Google App Engine

Google App Engine에 컨테이너 애플리케이션 배포하기

Minku Lee

December 22, 2017
Tweet

More Decks by Minku Lee

Other Decks in Technology

Transcript

  1. Containers @ Google App Engine
    Minku Lee
    CTO

    View full-size slide

  2. Shakr Infrastructure

    View full-size slide

  3. Shakr Infrastructure
    • 2014
    • 2015 GCP
    • 2016 Google Kubernetes Engine
    • 2017 GKE

    View full-size slide

  4. ੉੹
    Harder, better, faster, stronger
    with Google Container Engine
    ҳӖஶప੉ցূ૓ਸࢎਊೠࡅܰҊউ੿੸ੋࢲ࠺झѐߊ߂ߓನ
    CTO
    MINKU LEE
    2016.12 2017.07

    View full-size slide

  5. Containers @ Google App Engine
    Minku Lee
    CTO

    View full-size slide

  6. Google Cloud

    View full-size slide

  7. Kubernetes Engine
    Containers on Compute Engine
    App Engine Flex

    View full-size slide

  8. Kubernetes Engine
    Containers on Compute Engine
    App Engine Flex

    View full-size slide

  9. DaemonSet
    Deployment
    Job
    Pod
    ReplicaSet
    StatefulSet
    Ingress
    Service
    ConfigMap
    Secret
    PersistentVolumeClaim

    View full-size slide

  10. " "
    Express
    Django
    Phoenix
    Play
    Rails

    View full-size slide

  11. Kubernetes Engine
    Containers on Compute Engine
    App Engine Flex

    View full-size slide

  12. Kubernetes Engine
    Containers on Compute Engine
    App Engine Flex

    View full-size slide

  13. App Engine
    Flexible Environment

    View full-size slide

  14. Flexible Environment
    • Docker !
    • SSH
    • VM vCPU, ,

    View full-size slide

  15. Standard
    • Health check
    • Autoscaling
    • Traffic split

    View full-size slide

  16. Dockerfile
    FROM ruby:2.4.1
    ENV RAILS_ENV production
    ENV RAILS_LOG_TO_STDOUT true
    ENV RAILS_SERVE_STATIC_FILES true
    ENV PORT 8080
    ADD . /opt/translator
    WORKDIR /opt/translator
    # Install Ruby dependencies
    RUN bundle install
    # Precompile assets
    RUN rake assets:precompile
    EXPOSE 8080
    CMD ["./bin/rails", "server"]

    View full-size slide

  17. Dockerfile
    FROM ruby:2.4.1
    ENV RAILS_ENV production
    ENV RAILS_LOG_TO_STDOUT true
    ENV RAILS_SERVE_STATIC_FILES true
    ENV PORT 8080
    ADD . /opt/translator
    WORKDIR /opt/translator
    # Install Ruby dependencies
    RUN bundle install
    # Precompile assets
    RUN rake assets:precompile
    EXPOSE 8080
    CMD ["./bin/rails", "server"]

    View full-size slide

  18. Dockerfile
    FROM ruby:2.4.1
    ENV RAILS_ENV production
    ENV RAILS_LOG_TO_STDOUT true
    ENV RAILS_SERVE_STATIC_FILES true
    ENV PORT 8080
    ADD . /opt/translator
    WORKDIR /opt/translator
    # Install Ruby dependencies
    RUN bundle install
    # Precompile assets
    RUN rake assets:precompile
    EXPOSE 8080
    CMD ["./bin/rails", "server"]

    View full-size slide

  19. Dockerfile
    FROM ruby:2.4.1
    ENV RAILS_ENV production
    ENV RAILS_LOG_TO_STDOUT true
    ENV RAILS_SERVE_STATIC_FILES true
    ENV PORT 8080
    ADD . /opt/translator
    WORKDIR /opt/translator
    # Install Ruby dependencies
    RUN bundle install
    # Precompile assets
    RUN rake assets:precompile
    EXPOSE 8080
    CMD ["./bin/rails", "server"]

    View full-size slide

  20. Dockerfile
    FROM ruby:2.4.1
    ENV RAILS_ENV production
    ENV RAILS_LOG_TO_STDOUT true
    ENV RAILS_SERVE_STATIC_FILES true
    ENV PORT 8080
    ADD . /opt/translator
    WORKDIR /opt/translator
    # Install Ruby dependencies
    RUN bundle install
    # Precompile assets
    RUN rake assets:precompile
    EXPOSE 8080
    CMD ["./bin/rails", "server"]

    View full-size slide

  21. Dockerfile
    FROM ruby:2.4.1
    ENV RAILS_ENV production
    ENV RAILS_LOG_TO_STDOUT true
    ENV RAILS_SERVE_STATIC_FILES true
    ENV PORT 8080
    ADD . /opt/translator
    WORKDIR /opt/translator
    # Install Ruby dependencies
    RUN bundle install
    # Precompile assets
    RUN rake assets:precompile
    EXPOSE 8080
    CMD ["./bin/rails", "server"]

    View full-size slide

  22. Dockerfile
    FROM ruby:2.4.1
    ENV RAILS_ENV production
    ENV RAILS_LOG_TO_STDOUT true
    ENV RAILS_SERVE_STATIC_FILES true
    ENV PORT 8080
    ADD . /opt/translator
    WORKDIR /opt/translator
    # Install Ruby dependencies
    RUN bundle install
    # Precompile assets
    RUN rake assets:precompile
    EXPOSE 8080
    CMD ["./bin/rails", "server"]

    View full-size slide

  23. Dockerfile
    FROM ruby:2.4.1
    ENV RAILS_ENV production
    ENV RAILS_LOG_TO_STDOUT true
    ENV RAILS_SERVE_STATIC_FILES true
    ENV PORT 8080
    ADD . /opt/translator
    WORKDIR /opt/translator
    # Install Ruby dependencies
    RUN bundle install
    # Precompile assets
    RUN rake assets:precompile
    EXPOSE 8080
    CMD ["./bin/rails", "server"]

    View full-size slide

  24. Dockerfile
    • App Engine 

    Docker
    Kubernetes 


    View full-size slide

  25. $ docker build -t translator .
    Sending build context to Docker daemon 3.723MB
    Step 1/16 : FROM ruby:2.4.1
    ---> 3630c02d3d1b
    Step 2/16 : ENV RAILS_ENV production
    ---> 2a12ea7c6eef
    (઺ۚ)
    Step 13/16 : RUN bundle install
    ---> Running in f2a52936b83d
    Fetching gem metadata from https://rubygems.org/.........
    (઺ۚ)
    ---> 1f57192986de
    Step 16/16 : CMD ./bin/rails server
    ---> Running in b8b2bab7504c
    ---> dc51ead245a0
    Removing intermediate container b8b2bab7504c
    Successfully built dc51ead245a0
    Successfully tagged translator:latest

    View full-size slide

  26. $ docker run \
    -p 8080:8080 \
    -e SECRET_KEY_BASE=XXX \
    translator:latest
    => Booting Puma
    => Rails 5.1.3 application starting in production on
    http://0.0.0.0:8080
    => Run `rails server -h` for more startup options
    Puma starting in single mode...

    View full-size slide

  27. $ docker run \
    -p 8080:8080 \
    -e SECRET_KEY_BASE=XXX \
    translator:latest
    => Booting Puma
    => Rails 5.1.3 application starting in production on
    http://0.0.0.0:8080
    => Run `rails server -h` for more startup options
    Puma starting in single mode...

    View full-size slide

  28. app.yaml
    Google Cloud SDK
    gcloud app deploy

    View full-size slide

  29. app.yaml
    runtime: custom
    env: flex
    skip_files:
    - .env
    - tmp/
    - node_modules
    resources:
    cpu: 1
    memory_gb: 1
    disk_size_gb: 10
    liveness_check:
    path: '/_internal/checks/health'
    check_interval_sec: 5
    timeout_sec: 5
    failure_threshold: 2
    success_threshold: 2
    readiness_check:
    path: '/_internal/checks/ready'
    check_interval_sec: 5
    timeout_sec: 5
    failure_threshold: 2
    success_threshold: 2
    app_start_timeout_sec: 300
    automatic_scaling:
    min_num_instances: 1
    max_num_instances: 10
    cool_down_period_sec: 120
    cpu_utilization:
    target_utilization: 0.6
    env_variables:
    SECRET_KEY_BASE: 'XXX'

    View full-size slide

  30. app.yaml
    runtime: custom
    env: flex
    skip_files:
    - .env
    - tmp/
    - node_modules
    resources:
    cpu: 1
    memory_gb: 1
    disk_size_gb: 10
    liveness_check:
    path: '/_internal/checks/health'
    check_interval_sec: 5
    timeout_sec: 5
    failure_threshold: 2
    success_threshold: 2
    readiness_check:
    path: '/_internal/checks/ready'
    check_interval_sec: 5
    timeout_sec: 5
    failure_threshold: 2
    success_threshold: 2
    app_start_timeout_sec: 300
    automatic_scaling:
    min_num_instances: 1
    max_num_instances: 10
    cool_down_period_sec: 120
    cpu_utilization:
    target_utilization: 0.6
    env_variables:
    SECRET_KEY_BASE: 'XXX'

    View full-size slide

  31. app.yaml
    runtime: custom
    env: flex
    skip_files:
    - .env
    - tmp/
    - node_modules
    resources:
    cpu: 1
    memory_gb: 1
    disk_size_gb: 10
    liveness_check:
    path: '/_internal/checks/health'
    check_interval_sec: 5
    timeout_sec: 5
    failure_threshold: 2
    success_threshold: 2
    readiness_check:
    path: '/_internal/checks/ready'
    check_interval_sec: 5
    timeout_sec: 5
    failure_threshold: 2
    success_threshold: 2
    app_start_timeout_sec: 300
    automatic_scaling:
    min_num_instances: 1
    max_num_instances: 10
    cool_down_period_sec: 120
    cpu_utilization:
    target_utilization: 0.6
    env_variables:
    SECRET_KEY_BASE: 'XXX'

    View full-size slide

  32. app.yaml
    runtime: custom
    env: flex
    skip_files:
    - .env
    - tmp/
    - node_modules
    resources:
    cpu: 1
    memory_gb: 1
    disk_size_gb: 10
    liveness_check:
    path: '/_internal/checks/health'
    check_interval_sec: 5
    timeout_sec: 5
    failure_threshold: 2
    success_threshold: 2
    readiness_check:
    path: '/_internal/checks/ready'
    check_interval_sec: 5
    timeout_sec: 5
    failure_threshold: 2
    success_threshold: 2
    app_start_timeout_sec: 300
    automatic_scaling:
    min_num_instances: 1
    max_num_instances: 10
    cool_down_period_sec: 120
    cpu_utilization:
    target_utilization: 0.6
    env_variables:
    SECRET_KEY_BASE: 'XXX'

    View full-size slide

  33. Memory calculation

    View full-size slide

  34. app.yaml
    runtime: custom
    env: flex
    skip_files:
    - .env
    - tmp/
    - node_modules
    resources:
    cpu: 1
    memory_gb: 1
    disk_size_gb: 10
    liveness_check:
    path: '/_internal/checks/health'
    check_interval_sec: 5
    timeout_sec: 5
    failure_threshold: 2
    success_threshold: 2
    readiness_check:
    path: '/_internal/checks/ready'
    check_interval_sec: 5
    timeout_sec: 5
    failure_threshold: 2
    success_threshold: 2
    app_start_timeout_sec: 300
    automatic_scaling:
    min_num_instances: 1
    max_num_instances: 10
    cool_down_period_sec: 120
    cpu_utilization:
    target_utilization: 0.6
    env_variables:
    SECRET_KEY_BASE: 'XXX'

    View full-size slide

  35. Health check
    health_check 

    7 liveness readiness check
    • Liveness check 

    • Readiness check 


    View full-size slide

  36. app.yaml
    runtime: custom
    env: flex
    skip_files:
    - .env
    - tmp/
    - node_modules
    resources:
    cpu: 1
    memory_gb: 1
    disk_size_gb: 10
    liveness_check:
    path: '/_internal/checks/health'
    check_interval_sec: 5
    timeout_sec: 5
    failure_threshold: 2
    success_threshold: 2
    readiness_check:
    path: '/_internal/checks/ready'
    check_interval_sec: 5
    timeout_sec: 5
    failure_threshold: 2
    success_threshold: 2
    app_start_timeout_sec: 300
    automatic_scaling:
    min_num_instances: 1
    max_num_instances: 10
    cool_down_period_sec: 120
    cpu_utilization:
    target_utilization: 0.6
    env_variables:
    SECRET_KEY_BASE: 'XXX'

    View full-size slide

  37. app.yaml
    runtime: custom
    env: flex
    skip_files:
    - .env
    - tmp/
    - node_modules
    resources:
    cpu: 1
    memory_gb: 1
    disk_size_gb: 10
    liveness_check:
    path: '/_internal/checks/health'
    check_interval_sec: 5
    timeout_sec: 5
    failure_threshold: 2
    success_threshold: 2
    readiness_check:
    path: '/_internal/checks/ready'
    check_interval_sec: 5
    timeout_sec: 5
    failure_threshold: 2
    success_threshold: 2
    app_start_timeout_sec: 300
    automatic_scaling:
    min_num_instances: 1
    max_num_instances: 10
    cool_down_period_sec: 120
    cpu_utilization:
    target_utilization: 0.6
    env_variables:
    SECRET_KEY_BASE: 'XXX'

    View full-size slide

  38. app.yaml (manual scaling)
    runtime: custom
    env: flex
    skip_files:
    - .env
    - tmp/
    - node_modules
    resources:
    cpu: 1
    memory_gb: 1
    disk_size_gb: 10
    liveness_check:
    path: '/_internal/checks/health'
    check_interval_sec: 5
    timeout_sec: 5
    failure_threshold: 2
    success_threshold: 2
    readiness_check:
    path: '/_internal/checks/ready'
    check_interval_sec: 5
    timeout_sec: 5
    failure_threshold: 2
    success_threshold: 2
    app_start_timeout_sec: 300
    manual_scaling:
    instances: 10
    env_variables:
    SECRET_KEY_BASE: 'XXX'

    View full-size slide

  39. app.yaml
    runtime: custom
    env: flex
    skip_files:
    - .env
    - tmp/
    - node_modules
    resources:
    cpu: 1
    memory_gb: 1
    disk_size_gb: 10
    liveness_check:
    path: '/_internal/checks/health'
    check_interval_sec: 5
    timeout_sec: 5
    failure_threshold: 2
    success_threshold: 2
    readiness_check:
    path: '/_internal/checks/ready'
    check_interval_sec: 5
    timeout_sec: 5
    failure_threshold: 2
    success_threshold: 2
    app_start_timeout_sec: 300
    automatic_scaling:
    min_num_instances: 1
    max_num_instances: 10
    cool_down_period_sec: 120
    cpu_utilization:
    target_utilization: 0.6
    env_variables:
    SECRET_KEY_BASE: 'XXX'

    View full-size slide

  40. app.yaml
    Google Cloud SDK
    gcloud app deploy

    View full-size slide

  41. app.yaml
    Google Cloud SDK
    gcloud app deploy

    View full-size slide

  42. App Engine
    $ gcloud app create
    You are creating an app for project [project-id].
    WARNING: Creating an App Engine application for a project is irreversible and the region
    cannot be changed. More information about regions is at
    https://cloud.google.com/appengine/docs/locations.
    Please choose the region where you want your App Engine application
    located:
    [1] us-central (supports standard and flexible)
    (઺ۚ)
    [6] asia-northeast1 (supports standard and flexible)
    (઺ۚ)
    [9] cancel
    Please enter your numeric choice: 6
    Creating App Engine application in project [project-id] and region [asia-northeast1]....done.
    Success! The app is now created. Please use `gcloud app deploy` to deploy your first app.

    View full-size slide

  43. $ gcloud app deploy
    Services to deploy:
    descriptor: [/Users/premist/dev/translator/app.yaml]
    source: [/Users/premist/dev/translator]
    target project: [sample-project-id]
    target service: [default]
    target version: [20170822t013314]
    target url: [https://sample-project-id.appspot.com]
    Do you want to continue (Y/n)? y
    If this is your first deployment, this may take a while...done.
    Beginning deployment of service [default]...
    Updating service [default]...done.
    Deployed service [default] to [https://sample-project-id.appspot.com]
    You can stream logs from the command line by running:
    $ gcloud app logs tail -s default
    To view your application in the web browser run:
    $ gcloud app browse

    View full-size slide

  44. Under the hood

    View full-size slide

  45. Cloud SDK
    User's Computer
    Google Cloud
    Cloud Storage
    Cloud
    Container Builder
    App Engine
    Source upload

    View full-size slide

  46. Cloud SDK
    User's Computer
    Google Cloud
    Cloud Storage
    Cloud
    Container Builder
    App Engine
    Source upload Trigger build

    View full-size slide

  47. Cloud SDK
    User's Computer
    Google Cloud
    Cloud Storage
    Cloud
    Container Builder
    App Engine
    Source upload Trigger build
    Create new version

    View full-size slide

  48. Cloud SDK
    User's Computer
    Google Cloud
    Cloud Storage
    Cloud
    Container Builder
    App Engine
    Source upload Trigger build
    Create new version
    Wait for version to be ready

    View full-size slide

  49. Cloud SDK
    User's Computer
    Google Cloud
    Cloud Storage
    Cloud
    Container Builder
    App Engine
    Source upload Trigger build
    Create new version
    Wait for version to be ready
    Update traffic split

    View full-size slide

  50. $ gcloud app deploy

    View full-size slide

  51. Stackdriver Monitoring

    View full-size slide

  52. $ gcloud app logs tail

    View full-size slide

  53. Cloud Console

    View full-size slide

  54. App Engine
    Flexible Environment

    View full-size slide

  55. Ruby on Rails

    View full-size slide

  56. Ruby on Rails
    App Engine Flex 30

    View full-size slide

  57. Ruby on Rails
    App Engine Flex 30
    Cloud IAP

    View full-size slide

  58. Ruby on Rails
    App Engine Flex 30
    Cloud IAP

    View full-size slide

  59. Ruby on Rails
    App Engine Flex 30
    Cloud IAP

    View full-size slide

  60. ...
    (Cloud Security Scanner)
    canary
    SSL
    • Stackdriver Tracing, Debugger, Error Reporting, …

    View full-size slide

  61. Stackdriver Trace

    View full-size slide

  62. Stackdriver Trace

    View full-size slide

  63. TL;DR


    App Engine
    App Engine Standard

    Flexible Environment

    View full-size slide

  64. gRPC 

    Non-HTTP 

    Kubernetes Engine
    Standard ജ҃ীח ੓ח ૑୹ ೠب ӝמ੉ হ׮
    Compute Engine

    View full-size slide

  65. Iowa
    Compute Engine:
    1
    App Engine
    Compute Engine
    Standard Sustained
    $42.984/mo
    $96.192/mo
    $223.056/mo
    Memory
    vCPU
    1GB
    2 4GB
    4 14GB
    Preemptible
    $27.0864/mo
    $60.57504/mo
    $140.3568/mo
    $19.3/mo
    $43.3/mo
    $100.7/mo
    $6.79/mo
    $14.89/mo
    $35.09/mo

    View full-size slide

  66. Iowa
    Heroku: Standard-2X, P-M, P-L
    1
    App Engine
    $42.984/mo
    $88.524/mo
    $223.056/mo
    Memory
    vCPU
    1GB
    2 2.5GB
    4 14GB
    $50/mo
    $250/mo
    $500/mo
    Heroku

    View full-size slide

  67. Thank you!
    .
    bit.ly/shakr-gae-flex
    Shakr .
    careers.shakr.com

    View full-size slide