myfirst buildpack session_mgmt_20161201
TRANSCRIPT
Buildpackのはじめかた杉原智衛カスタマーエンジニア Global Support Services, Pivotal
目的• Buildpack の概要• サンプルアプリケーションをデプロイ• Buildpack の内部動作• Buildpack のカスタマイズ• Buildpack の管理
Buildpack とは• 実行環境を提供し OS ・ミドルウェアを隠蔽
– 開発者は bulidpack のみを意識してアプリケーションを開発– OS やミドルウェア・フレームワークの管理から開放
• java/ruby/php/nodejs/python など built-inとして CFコミュニティが開発・保守– 言語ごとにに作法( code の配置、設定など)は異なるが、 CF
API による操作、 CF プラットフォームからの呼び出しは統一的
準備• 準備
– 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
Buildpackにふれてみよう$ cf buildpacks$ cf help -a | grep buildpack$ cf push APP_NAME (-b PATH_TO_BP)
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
サンプルアプリをうごかしてみよう• サンプル集• Cloud foundry へ push
– git clone REPO_URL && cd REPO_NAME– cf push
内部動作• bin/detect: push されたアプリに適合する buildpackかどうかを検知する• bin/compile: アプリをパッケージ化して droplet を作成する• bin/release: CF にどのように実行するかを伝える
カスタム buildpack
•https://github.com/tomoe/mybp/• cf push -m 128M -b
https://github.com/Pivotal-Japan/sample-custom-buildpack test-with-mybp
まとめ• Buildpack の意味・動作・カスタマイズ・管理方法をざっくりと説明しました• cloudfoundry によるアプリ開発ができるようになっていただいた(はず)
参考リンク• https://github.com/Pivotal-Japan/cf-workshop• built-in buildpacks• Buildpack/rootfs/stemcell解説
Cloud FoundrySession Management
Tao DengCustomer Engineer
prerequisite• cf cli
https://github.com/cloudfoundry/cli/releases• PWS account sign-up for free at
http://run.pivotal.io• git• maven
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
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
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
Push app to Cloud Foundry1.mvn package2.cf push3.cf scale APP_NAME -i 4
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.
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
A NEW PLATFORM FOR A NEW ERA