myfirst buildpack session_mgmt_20161201

20
Buildpack のののののの 杉杉杉杉 杉杉杉杉杉杉杉杉杉杉 Global Support Services, Pivotal

Upload: tomohiro-ichimura

Post on 13-Apr-2017

274 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: Myfirst buildpack session_mgmt_20161201

Buildpackのはじめかた杉原智衛カスタマーエンジニア Global Support Services, Pivotal

Page 2: Myfirst buildpack session_mgmt_20161201

目的• Buildpack の概要• サンプルアプリケーションをデプロイ• Buildpack の内部動作• Buildpack のカスタマイズ• Buildpack の管理

Page 3: Myfirst buildpack session_mgmt_20161201

Buildpack とは• 実行環境を提供し OS ・ミドルウェアを隠蔽

– 開発者は bulidpack のみを意識してアプリケーションを開発– OS やミドルウェア・フレームワークの管理から開放

• java/ruby/php/nodejs/python など built-inとして CFコミュニティが開発・保守– 言語ごとにに作法( code の配置、設定など)は異なるが、 CF

API による操作、 CF プラットフォームからの呼び出しは統一的

Page 4: Myfirst buildpack session_mgmt_20161201

準備• 準備

– CF CLIのインストール– CloudFoundry へのアクセス

▪ Pivotal Web Servicesをつかいます▪ $ cf login -a https://api.run.pivotal.io

• 参考– https://github.com/Pivotal-Japan/cf-workshop/bl

ob/master/prerequisite.md

Page 5: Myfirst buildpack session_mgmt_20161201

Buildpackにふれてみよう$ cf buildpacks$ cf help -a | grep buildpack$ cf push APP_NAME (-b PATH_TO_BP)

Page 6: Myfirst buildpack session_mgmt_20161201

php_buildpack• 30秒チュートリアル

$ mkdir my-php-app$ cd my-php-app$ cat << EOF > index.php<?php phpinfo();?>EOF$ cf push -m 128M -b https://github.com/cloudfoundry/php-buildpack.git my-php-app

Page 7: Myfirst buildpack session_mgmt_20161201

サンプルアプリをうごかしてみよう• サンプル集• Cloud foundry へ push

– git clone REPO_URL && cd REPO_NAME– cf push

Page 8: Myfirst buildpack session_mgmt_20161201

内部動作• bin/detect: push されたアプリに適合する buildpackかどうかを検知する• bin/compile: アプリをパッケージ化して droplet を作成する• bin/release: CF にどのように実行するかを伝える

Page 9: Myfirst buildpack session_mgmt_20161201

カスタム buildpack

•https://github.com/tomoe/mybp/• cf push -m 128M -b

https://github.com/Pivotal-Japan/sample-custom-buildpack test-with-mybp

Page 10: Myfirst buildpack session_mgmt_20161201

まとめ• Buildpack の意味・動作・カスタマイズ・管理方法をざっくりと説明しました• cloudfoundry によるアプリ開発ができるようになっていただいた(はず)

Page 12: Myfirst buildpack session_mgmt_20161201

Cloud FoundrySession Management

Tao DengCustomer Engineer

Page 13: Myfirst buildpack session_mgmt_20161201

prerequisite• cf cli

https://github.com/cloudfoundry/cli/releases• PWS account sign-up for free at

http://run.pivotal.io• git• maven

Page 14: Myfirst buildpack session_mgmt_20161201

Instance 1

Instance 4

Instance 2

Instance 3

Red

is, G

emfir

e

Load

Bal

ance

r + R

oute

rs

stick

y ses

sion session share

Cloud Foundry

Page 15: Myfirst buildpack session_mgmt_20161201

Sticky Session• blog by pivots (James Bayer)

– http://www.iamjambay.com/2013/10/a-quick-tour-of-cloud-foundry-router.html

• source code– https://github.com/jbayer/cloudfoundry-sticky-session

Page 16: Myfirst buildpack session_mgmt_20161201

Edit manifest.yml

1. git clone https://github.com/jbayer/cloudfoundry-sticky-session2. cd cloudfoundry-sticky-session3. add manifest.yml

---applications:- name: sticky-session memory: 256M instances: 4 host: <any unique string here> path: ./target/StickySessionApp-1.0.war buildpack: java_buildpack

Page 17: Myfirst buildpack session_mgmt_20161201

Push app to Cloud Foundry1.mvn package2.cf push3.cf scale APP_NAME -i 4

Page 18: Myfirst buildpack session_mgmt_20161201

DemoTo support sticky sessions, applications must return a JSESSIONID cookie in responses.

If an application returns a JSESSIONID cookie to a client request, the CF routing tier appends a second cookie, called VCAP_ID, containing a unique identifier for the application instance. On subsequent requests, the client must provide both the JSESSIONID and VCAP_ID cookies. The CF routing tier uses the VCAP_ID to forward client requests to the same application instance every time.

Page 19: Myfirst buildpack session_mgmt_20161201

Instance X 1

Load Balancer + RoutersClient(Browser) App Instances

1. http request 2.http request

3.http response(JSESSIONID cookie)

5.http requestJSESSIONID cookie +

VCAP_ID cookie

4.http responseJSESSIONID cookie +

VCAP_ID cookie

6. to same instance

Datagram

Instance ...1

Instance ...1

Instance ...1

Page 20: Myfirst buildpack session_mgmt_20161201

A NEW PLATFORM FOR A NEW ERA