Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

myself

Slide 3

Slide 3 text

Motivation - Be a cloud- friendly engineer

Slide 4

Slide 4 text

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 お祈りデプロイ)

Slide 5

Slide 5 text

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"]

Slide 6

Slide 6 text

!!!One great way to learn modern web dev is going through cloud technology !!!

Slide 7

Slide 7 text

Eye-opening Experience - Google AppEngine and me

Slide 8

Slide 8 text

GCP Workshop

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

注意 ● 課金されるかもごめんね ● 経験者が多いので難しめです ● 途中から来ないでもいいよ

Slide 11

Slide 11 text

Overview at Cloud tech.

Slide 12

Slide 12 text

Cloud tech. ● IaaS ● PaaS ● mBaaS ● FaaS ● (orchestration tool)

Slide 13

Slide 13 text

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 ●

Slide 14

Slide 14 text

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 ●

Slide 15

Slide 15 text

mBaaS: Mobile Backend as a Service ● Such as; Firebase, Parse.com(dead) ● For Mobile(iPhone app, Android App) ● Datastore, Authentication, Push, ads, ...

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

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:

Slide 20

Slide 20 text

Orchestration ● Hosting; Elastic Container Service, Google Container Engine(GKE) ● Tool; Docker swarm, Docker compose, Kubernetes ●

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

Why GCP ● AWS is the biggest player, though ● GCP is ○ Cheap ○ Cutting-edge ○ Made by Google ○ For Startups ○

Slide 23

Slide 23 text

Adopted by cutting-edge companies ● Pokemon Go, Nintendo (AppEngine) ● メルカリアッテ, Mercali (AppEngine) ● Abema TV, Cyberagent (GCE, GKE) ● DeNA (AppEngine) ●

Slide 24

Slide 24 text

Any questions?

Slide 25

Slide 25 text

Let’s start with workshop

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

Console ● Dashboard ● Project ● Menu (〓)

Slide 28

Slide 28 text

Horror story; AWS 破産 ● GCP has wider free tier than AWS but… ● Charging point ○ Instance ○ Storage ○ Traffic ○ API calls ●

Slide 29

Slide 29 text

Set a budget alert ● Notice earlier when forget to turning off a instance ● [〓] → billing → `Budgets & alerts` → `CREATE BUDGET` ● Input like this ●

Slide 30

Slide 30 text

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

Slide 31

Slide 31 text

Launch a Wordpress ● https://console.cloud.google.com/launch er ● Select `wordpress`

Slide 32

Slide 32 text

Tour VMs ● https://console.cloud.google.com/compu te/instances → click `wordpress-1` ● [SSH] ● [STOP] Disks !!!

Slide 33

Slide 33 text

VM ● Zone ● Machine Type - CPU/Memory ● OS ● Storage ● Firewall ●

Slide 34

Slide 34 text

Delete VM & Project ● VM instances → [DELETE] ● Delete Project https://console.cloud.google.com/cloud-resource-man ager ○ Type project id ● まめに消すこと

Slide 35

Slide 35 text

Pricing ● https://cloud.google.com/compute/pricing ● Point ○ CPU ○ Volume ○ Traffic ○ Always Free

Slide 36

Slide 36 text

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

Slide 37

Slide 37 text

Take a break

Slide 38

Slide 38 text

Setup cloud sdk - `gcloud init`

Slide 39

Slide 39 text

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`

Slide 40

Slide 40 text

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

Slide 41

Slide 41 text

Ssh an instance - `gcloud compute ssh instance-1`

Slide 42

Slide 42 text

Delete - `gcloud compute instances delete instance1`

Slide 43

Slide 43 text

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

Slide 44

Slide 44 text

演習 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

Slide 45

Slide 45 text

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を作ってください

Slide 46

Slide 46 text

次回 ● Dockernize ● Network ● Cost estimation ● もうちょっと現実的な構成 ● App Server Compute Engine Autoscaling App Server Compute Engine Autoscaling Cloud Load Balancing

Slide 47

Slide 47 text

Homework ● Install docker