Containers @ Google App Engine

91b2bf7b681403e98e6846677d9ca029?s=47 Minku Lee
December 22, 2017

Containers @ Google App Engine

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

91b2bf7b681403e98e6846677d9ca029?s=128

Minku Lee

December 22, 2017
Tweet

Transcript

  1. Containers @ Google App Engine Minku Lee CTO

  2. !

  3. None
  4. None
  5. None
  6. None
  7. None
  8. None
  9. None
  10. Shakr Infrastructure

  11. Shakr Infrastructure • 2014 • 2015 GCP • 2016 Google

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

    CTO MINKU LEE 2016.12 2017.07
  13. Containers @ Google App Engine Minku Lee CTO

  14. None
  15. Google Cloud

  16. Kubernetes Engine Containers on Compute Engine App Engine Flex

  17. Kubernetes Engine Containers on Compute Engine App Engine Flex

  18. None
  19. None
  20. None
  21. None
  22. None
  23. None
  24. None
  25. None
  26. GKE

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

    PersistentVolumeClaim
  28. " " Express Django Phoenix Play Rails

  29. Kubernetes Engine Containers on Compute Engine App Engine Flex

  30. None
  31. None
  32. Kubernetes Engine Containers on Compute Engine App Engine Flex

  33. App Engine Flexible Environment

  34. App Engine

  35. App Engine

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

    ,
  37. Standard • Health check • Autoscaling • Traffic split

  38. Rails

  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"]
  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"]
  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"]
  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"]
  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"]
  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"]
  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"]
  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"]
  47. Dockerfile • App Engine 
 Docker Kubernetes 


  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
  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...
  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...
  51. App Engine

  52. app.yaml Google Cloud SDK gcloud app deploy

  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'
  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'
  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'
  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'
  57. Memory calculation

  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'
  59. Health check health_check 
 7 liveness readiness check • Liveness

    check 
 • Readiness check 

  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'
  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'
  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'
  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'
  64. app.yaml Google Cloud SDK gcloud app deploy

  65. app.yaml Google Cloud SDK gcloud app deploy

  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.
  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
  68. None
  69. Under the hood

  70. Cloud SDK User's Computer Google Cloud Cloud Storage Cloud Container

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

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

    Builder App Engine Source upload Trigger build Create new version
  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
  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
  75. $ gcloud app deploy

  76. Monitoring

  77. App Engine

  78. Stackdriver Monitoring

  79. $ gcloud app logs tail

  80. Cloud Console

  81. None
  82. None
  83. ?

  84. None
  85. App Engine Flexible Environment

  86. Ruby on Rails

  87. Ruby on Rails App Engine Flex 30

  88. Ruby on Rails App Engine Flex 30 Cloud IAP

  89. Ruby on Rails App Engine Flex 30 Cloud IAP

  90. Cloud IAP

  91. G Suite

  92. Cloud IAP

  93. Cloud IAP

  94. Ruby on Rails App Engine Flex 30 Cloud IAP

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

    Error Reporting, …
  96. canary

  97. Stackdriver Trace

  98. Stackdriver Trace

  99. TL;DR 
 
 App Engine App Engine Standard 
 Flexible

    Environment
  100. gRPC 
 Non-HTTP 
 Kubernetes Engine Standard ജ҃ীח ੓ח ૑୹

    ೠب ӝמ੉ হ׮ Compute Engine
  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
  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
  103. Thank you! . bit.ly/shakr-gae-flex Shakr . careers.shakr.com