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 Slide

  2. !

    View Slide

  3. View Slide

  4. View Slide

  5. View Slide

  6. View Slide

  7. View Slide

  8. View Slide

  9. View Slide

  10. Shakr Infrastructure

    View Slide

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

    View Slide

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

    View Slide

  13. Containers @ Google App Engine
    Minku Lee
    CTO

    View Slide

  14. View Slide

  15. Google Cloud

    View Slide

  16. Kubernetes Engine
    Containers on Compute Engine
    App Engine Flex

    View Slide

  17. Kubernetes Engine
    Containers on Compute Engine
    App Engine Flex

    View Slide

  18. View Slide

  19. View Slide

  20. View Slide

  21. View Slide

  22. View Slide

  23. View Slide

  24. View Slide

  25. View Slide

  26. GKE

    View Slide

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

    View Slide

  28. " "
    Express
    Django
    Phoenix
    Play
    Rails

    View Slide

  29. Kubernetes Engine
    Containers on Compute Engine
    App Engine Flex

    View Slide

  30. View Slide

  31. View Slide

  32. Kubernetes Engine
    Containers on Compute Engine
    App Engine Flex

    View Slide

  33. App Engine
    Flexible Environment

    View Slide

  34. App Engine

    View Slide

  35. App Engine

    View Slide

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

    View Slide

  37. Standard
    • Health check
    • Autoscaling
    • Traffic split

    View Slide

  38. Rails

    View Slide

  39. 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 Slide

  40. 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 Slide

  41. 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 Slide

  42. 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 Slide

  43. 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 Slide

  44. 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 Slide

  45. 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 Slide

  46. 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 Slide

  47. Dockerfile
    • App Engine 

    Docker
    Kubernetes 


    View Slide

  48. $ 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 Slide

  49. $ 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 Slide

  50. $ 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 Slide

  51. App Engine

    View Slide

  52. app.yaml
    Google Cloud SDK
    gcloud app deploy

    View Slide

  53. 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 Slide

  54. 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 Slide

  55. 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 Slide

  56. 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 Slide

  57. Memory calculation

    View Slide

  58. 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 Slide

  59. Health check
    health_check 

    7 liveness readiness check
    • Liveness check 

    • Readiness check 


    View Slide

  60. 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 Slide

  61. 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 Slide

  62. 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 Slide

  63. 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 Slide

  64. app.yaml
    Google Cloud SDK
    gcloud app deploy

    View Slide

  65. app.yaml
    Google Cloud SDK
    gcloud app deploy

    View Slide

  66. 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 Slide

  67. $ 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 Slide

  68. View Slide

  69. Under the hood

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  73. 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 Slide

  74. 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 Slide

  75. $ gcloud app deploy

    View Slide

  76. Monitoring

    View Slide

  77. App Engine

    View Slide

  78. Stackdriver Monitoring

    View Slide

  79. $ gcloud app logs tail

    View Slide

  80. Cloud Console

    View Slide

  81. View Slide

  82. View Slide

  83. ?

    View Slide

  84. View Slide

  85. App Engine
    Flexible Environment

    View Slide

  86. Ruby on Rails

    View Slide

  87. Ruby on Rails
    App Engine Flex 30

    View Slide

  88. Ruby on Rails
    App Engine Flex 30
    Cloud IAP

    View Slide

  89. Ruby on Rails
    App Engine Flex 30
    Cloud IAP

    View Slide

  90. Cloud IAP

    View Slide

  91. G Suite

    View Slide

  92. Cloud IAP

    View Slide

  93. Cloud IAP

    View Slide

  94. Ruby on Rails
    App Engine Flex 30
    Cloud IAP

    View Slide

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

    View Slide

  96. canary

    View Slide

  97. Stackdriver Trace

    View Slide

  98. Stackdriver Trace

    View Slide

  99. TL;DR


    App Engine
    App Engine Standard

    Flexible Environment

    View Slide

  100. gRPC 

    Non-HTTP 

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

    View Slide

  101. 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 Slide

  102. 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 Slide

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

    View Slide