GCP_WORKSHOP_1_GCE

7a1631691f372ed25308ba9ccd727b2d?s=47 iwagami
December 15, 2017

 GCP_WORKSHOP_1_GCE

* Overview of GCP
* GCE

7a1631691f372ed25308ba9ccd727b2d?s=128

iwagami

December 15, 2017
Tweet

Transcript

  1. GCP Workshop Dec 2nd, 2017 Gammy (Takuya Iwakami)

  2. myself

  3. Motivation - Be a cloud- friendly engineer

  4. Once upon a time, (90s - 2000s) Working with a

    web application, you used to use • Physical servers • Instruction text • Historical shell script • Deploy and pray (aka お祈りデプロイ)
  5. 201x - Now, we have Cloud tech. & Configuration files!!!

    - Dockerfile, Procfile, etc. Doing deploy is only .. - git push - press deploy button - speak to chatbot Eg. Configuration file FROM ruby:2.3 # throw errors if Gemfile has been modified since Gemfile.lock RUN bundle config --global frozen 1 RUN mkdir -p /usr/src/app WORKDIR /usr/src/app ONBUILD COPY Gemfile /usr/src/app/ ONBUILD COPY Gemfile.lock /usr/src/app/ ONBUILD RUN bundle install ONBUILD COPY . /usr/src/app RUN apt-get update && apt-get install -y nodejs --no-install-recommends && rm -rf /var/lib/apt/lists/* RUN apt-get update && apt-get install -y mysql-client postgresql-client sqlite3 --no-install-recommends && rm -rf /var/lib/apt/lists/* EXPOSE 3000 CMD ["rails", "server", "-b", "0.0.0.0"]
  6. !!!One great way to learn modern web dev is going

    through cloud technology !!!
  7. Eye-opening Experience - Google AppEngine and me

  8. GCP Workshop

  9. Schecule • #1 12/2 GCP overview, GCE • #2 12/16

    GCE • #3 1/13? App Engine • #4 1/27? App Engine • #5 2/?? Kurbenetis • Gradually Difficult
  10. 注意 • 課金されるかもごめんね • 経験者が多いので難しめです • 途中から来ないでもいいよ

  11. Overview at Cloud tech.

  12. Cloud tech. • IaaS • PaaS • mBaaS • FaaS

    • (orchestration tool)
  13. IaaS: Infrastructure as a Service • Such as; Amazon EC2,

    Google Compute Engine (GCE) • Rental Infrastructure (server, data store, network) on demand ◦ Similar: virtual machine (VMWare, VirtualBox) • Build and run web application on freehand ◦ No restriction for user web application •
  14. PaaS: Platform as a Service • Such as; ElasticBeans, AppEngine,

    Heroku • Go publish web app by `git push` • Platform takes care of everything about web app ◦ Network, scaling, monitor, logging • Strong restriction ◦ Limited languages, frameworks, networks, version •
  15. mBaaS: Mobile Backend as a Service • Such as; Firebase,

    Parse.com(dead) • For Mobile(iPhone app, Android App) • Datastore, Authentication, Push, ads, ...
  16. FaaS: Function as a Service • Such as; Amazon Lambda,

    Cloud functions • Serverless - ultimate web app • Compose functions to make web app ◦ Charge per-function invocation • Stronger Restriction!! ◦ Languages(JS?), no framework, complete vendor lockin
  17. Orchestration • More and more complicate web application ◦ App

    Servers, Load balancer, Proxy server, Database, 3rd party API calls • Problems; ◦ Hard to manage a configuration or architecture ◦ Hard to set up in local environment • Describe a configuration of web application
  18. Regular Rails App in Cloud Nginx Redis PostgreSQL Compute Engine

    10GB PD 2 1 Compute Engine 10GB PD 1 Compute Engine 10GB PD 4 1 Compute Engine 10GB PD 4 1 Compute Engine 10GB PD 4 1 Rails Cloud Load Balancing Compute Engine 10GB PD 1 Cloud CDN
  19. Docker compose; wordpress version: '3' services: db: image: mysql:5.7 volumes:

    - db_data:/var/lib/mysql restart: always environment: MYSQL_ROOT_PASSWORD: somewordpress MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: wordpress wordpress: depends_on: - db image: wordpress:latest ports: - "8000:80" restart: always environment: WORDPRESS_DB_HOST: db:3306 WORDPRESS_DB_USER: wordpress WORDPRESS_DB_PASSWORD: wordpress volumes: db_data:
  20. Orchestration • Hosting; Elastic Container Service, Google Container Engine(GKE) •

    Tool; Docker swarm, Docker compose, Kubernetes •
  21. Map; GCP vs AWS 種類 GCP AWS IaaS GCE(G. Contaier

    Engine) EC2 Object Storage Cloud Storage S3 NoSQL DataStore Cloud datastore Dynano DB PaaS AppEngine Elastic Beanstalk SQL server Cloud SQL RDS BigData BigQuery Redshift mBaaS FireBase Amazon Mobile Serverless Cloud functions Amazon Lambda CDN Cloud CDN Cloud Front https://cloud.google.com/free/docs/map-aws-go ogle-cloud-platform?hl=ja
  22. Why GCP • AWS is the biggest player, though •

    GCP is ◦ Cheap ◦ Cutting-edge ◦ Made by Google ◦ For Startups ◦
  23. Adopted by cutting-edge companies • Pokemon Go, Nintendo (AppEngine) •

    メルカリアッテ, Mercali (AppEngine) • Abema TV, Cyberagent (GCE, GKE) • DeNA (AppEngine) •
  24. Any questions?

  25. Let’s start with workshop

  26. Login at console https://console.cloud.google.com/

  27. Console • Dashboard • Project • Menu (〓)

  28. Horror story; AWS 破産 • GCP has wider free tier

    than AWS but… • Charging point ◦ Instance ◦ Storage ◦ Traffic ◦ API calls •
  29. Set a budget alert • Notice earlier when forget to

    turning off a instance • [〓] → billing → `Budgets & alerts` → `CREATE BUDGET` • Input like this •
  30. Create first project • https://console.cloud.google.com/cloud-resour ce-manager • Click `CREATE PROJECT`

    • Type `helloworld` in project name and create • Wait a few min
  31. Launch a Wordpress • https://console.cloud.google.com/launch er • Select `wordpress`

  32. Tour VMs • https://console.cloud.google.com/compu te/instances → click `wordpress-1` • [SSH]

    • [STOP] Disks !!!
  33. VM • Zone • Machine Type - CPU/Memory • OS

    • Storage • Firewall •
  34. Delete VM & Project • VM instances → [DELETE] •

    Delete Project https://console.cloud.google.com/cloud-resource-man ager ◦ Type project id • まめに消すこと
  35. Pricing • https://cloud.google.com/compute/pricing • Point ◦ CPU ◦ Volume ◦

    Traffic ◦ Always Free
  36. Install Google Cloud SDK • Cloud SDK - Command line

    tool • Open Terminal.app and `brew cask install google-cloud-sdk` • https://cloud.google.com/sdk/gcloud/?hl=ja
  37. Take a break

  38. Setup cloud sdk - `gcloud init`

  39. Create project by cloud sdk - `gcloud projects create your-project-name`

    - Must be unieque ERROR: (gcloud.projects.create) Project creation failed. The project ID you specified is already in use by another project. Please try an alternative ID. - `gcloud config set project your-project-name`
  40. Create VM - `gcloud compute instances create gaminstance --machine-type f1-micro

    --image-family ubuntu-1710 --image-project ubuntu-os-cloud` - us-west-a https://cloud.google.com/compute/docs/instances/create -start-instance
  41. Ssh an instance - `gcloud compute ssh instance-1`

  42. Delete - `gcloud compute instances delete instance1`

  43. GCE Tutorial https://console.cloud.google.com/getting-started `Build a compute engine application`

  44. 演習 Rails • 次のインスタンスを作る ◦ MachineType: n1-standard / OS: Ubuntu

    16.04 / Zone: us-west/ allow-http-access • Ssh でインスタンスにログインする • Ruby をインストール • Rails をインストール • `rails new` • sudo ./bin/rails server -p 80 -b 0.0.0.0
  45. Shell script sudo apt-get update sudo apt-get install autoconf bison

    build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev sudo apt-get install ruby-dev sqlite3 libsqlite3-dev nodejs sudo gem install rails rails new HelloApp cd HelloApp # 元気のある人はDockerfileを作ってください
  46. 次回 • Dockernize • Network • Cost estimation • もうちょっと現実的な構成

    • App Server Compute Engine Autoscaling App Server Compute Engine Autoscaling Cloud Load Balancing
  47. Homework • Install docker