SlideShare uma empresa Scribd logo
1 de 36
Baixar para ler offline
Project OpenWhiskのご紹介
2016/3/18
第32回 PaaS勉強会
2016 @ibmamnt
自己紹介 ~
名前: 天野 武彦
所属:IBM 東京ソフトウェア開発研究所
主な活動: 先端クラウド技術の推進・啓蒙
(エリア: Cloud Foundry, DevOps, OpenStack, OpenWhisk 等)
趣味: 目下のところ育児に没頭
Twitter: @ibmamnt
ブログ: http://amanoblog.wordpress.com
2016 @ibmamnt
Project OpenWhisk
IBM Thomas J. Watson Research Centerの Cloud
Programing Technology Groupで研究開発
イベントに基づくプログラミングサービス
whisk (v) :
to move nimbly and quickly.
Source: merriam-webster.com
2016 @ibmamnt
2015 Softlayer & Bluemix Summit 基調講演
「仮想マシン(OpenStack)、ポータビリティ(Container)、コントロール(PaaS)の層にも注目すべ
きだ。Bluemixは、 OSS(Open Source Software)の「Cloud Foundry」をベースにするPaaSだが、それ
は全体の一部に過ぎないこと、および「Next」と表記された空白部分が存在することである。」
( http://it.impressbm.co.jp/articles/-/12762?page=2 から引用)
“特に後者のNextは
何を意味するのか?
浦本氏は特に言及し
なかった”
2016 @ibmamnt
そんなわけで、お仲間入り
OpenWhisk
2016 @ibmamnt
IBM Bluemix にもお仲間入り
アプリの構築を好きな方法で
アプリを作動させるために、最も広く知られたオープン・ソースのコ
ンピューティング・テクノロジーを組み合わせて使用します。 その
後、残りの処理は Bluemix に任せます。
軽量 フルスタック
OpenWhisk
Event-driven apps,
deployed in a serverless
environment.
2016 @ibmamnt
OpenWhisk の特徴
イベントに基づくプログラミングモデル
– イベントが発生すると1回起動し終了する。
複数言語、Docker コンテナ対応
–JavaScript, Swift (その他も計画中)
–Dockerコンテナ(C/C++, Golang 等なんでもあり)
Mobile バックエンドとして機能できる
– iOS SDK を提供 (Androidは開発中)
クラウド上で動作させスケールさせることができる
–現時点では IBM Bluemix がサービス提供(Experimental)
2016 @ibmamnt
OpenWhisk 概念図
詳細は後ほど
2016 @ibmamnt
そういえば、ここって
オープンPaaS勉強会だ
よね?
2016 @ibmamnt
OpenWhisk プロジェクト
https://github.com/openwhisk/openwhisk
• 開発構想時から OSS にすることを想
定(ベンダーロックインを排除)
• Cloud Foundry と似たようなエコシス
テムを目指す
• 技術パートナープログラムは近く発表
予定
2016 @ibmamnt
さて、PaaS か?
PaaSがアプリケーションを実⾏する基盤と定義するなら
ば・・・ある意味 PaaS と呼べるかも知れません
Cloud Foundry → 本格的なWEBアプリとマイクロサービ
スの基盤(常時起動)
OpenWhisk → イベント駆動型の小型アプリケーションの
基盤(イベント毎に起動)
2016 @ibmamnt
OpenWhisk 基本的な仕組み
2016 @ibmamnt
OpenWhisk 基本的な仕組み
action
– ステートレスな(小さな)コード
– 複数の action を登録できる
trigger
– イベントの受け口
rule
– trigger と action を紐付ける。trigger が
発火すると action がパラメータを受け
て実行される
package
– 外部サービスを利用するためのモ
ジュール群
– Bluemix では Watson, Weather などの
パッケージがある
2016 @ibmamnt
A Action: ステートレス関数(イベントハンドラー)
function main(params) {
console.log(“Hello “ + params.name);
return { msg: “Goodbye “ + params.name) };
}
2016 @ibmamnt
では、”Hello Whisk!”
function main() {
return { message: 'Hello world' };
}
$ wsk action create hello hello.js
ok: created action hello
$ wsk action list
actions
/IBMAMNT_dev/hello private
wsk action invoke --blocking hello
ok: invoked hello with id 4ba23dbcee7a4481a6e1e19818c745ec
response:
{
"result": {
"message": "Hello world"
},
"status": "success",
"statusCode": 200
}
activation id
※ main() が必要です
2016 @ibmamnt
外部API を呼び出す(パラメータ付き)
var request = require('request');
function main(msg) {
var location = msg.location || 'Tokyo';
var url = 'https://query.yahooapis.com/v1/public/yql?q=select item.condition from weather.forecast
where woeid in (select woeid from geo.places(1) where text="' + location + '")&format=json';
request.get(url, function(error, response, body) {
var condition = JSON.parse(body).query.results.channel.item.condition;
var text = condition.text;
var temperature = condition.temp;
temperature = 5*(temperature - 32)/9;
var output = 'It is ' + temperature + ' degrees in ' + location + ' and ' + text;
whisk.done({msg: output});
});
return whisk.async();
}
$ wsk action create weather weather.js
ok: created action weather
$ wsk action invoke weather -b -p location 'Tokyo' --result
{
"msg": "It is 10 degrees in Tokyo and Fair"
}
$ wsk action invoke weather -b -p location 'Sapporo' --result
{
"msg": "It is -2.2222222222222223 degrees in Sapporo and Light Snow
Shower"
}
パラメータ
パラメータ
2016 @ibmamnt
Action: シーケンス
A
:=
アクションを連鎖処理できます
(※今のところ他には無い特徴)
2016 @ibmamnt
Trigger
18
Trigger: 様々なイベントのクラス(feed)
OpenWhisk
2016 @ibmamnt
T A
event event handler
R Rule: Trigger から Action へのマッピング
Rule
2016 @ibmamnt
trigger と rule を作成する
$ wsk trigger create locationUpdate
ok: created trigger locationUpdate
$ wsk trigger list
triggers
/IBMAMNT_dev/locationUpdate private
$ wsk rule create myrule locationUpdate weather
ok: created rule myrule
$ wsk rule enable myrule
ok: rule myrule is activating
private
trigger の作成
rule の作成
trigger action
2016 @ibmamnt
trigger を fire (wsk trigger fire)
trigger を発火させると action 結果は activation リストに格
納されます
$ wsk trigger fire locationUpdate -p location 'Tokyo'
ok: triggered locationUpdate with id 3ef2c8d3d5054307b70a1a63e4554365
$ wsk trigger fire locationUpdate -p location 'Kyoto'
ok: triggered locationUpdate with id 2239603302a94930ac2dd8d295eb74d2
$ wsk activation list
activations
62986517dd034ee7b660dc9fe92e7067 weather
b43d07d0b8a94e5299d84beadc5bf000 weather
$ wsk activation result b43d07d0b8a94e5299d84beadc5bf000
{
"msg": "It is 8.88888888888889 degrees in Tokyo and Mostly Cloudy"
}
$ wsk activation result 62986517dd034ee7b660dc9fe92e7067
{
"msg": "It is 17.22222222222222 degrees in Kyoto and Mostly Cloudy"
}
2016 @ibmamnt
trigger の発火について
自アプリケーションから OpenWhisk の REST API をたたく
iOS SDK からたたく
Package の Feed を使って起動
この部分
※ 現時点では Package 作成のド
キュメントが整備されていません
(今後に期待)。
2016 @ibmamnt
REST api を直接たたく
• API end point
openwhisk.ng.bluemix.net/api/v1
• Swagger ドキュメント
http://petstore.swagger.io/?url=https://raw.githubusercontent.com/openw
hisk/openwhisk/master/core/controller/src/resources/whiskswagger.json
OpenWhisk をマイクロサービ
スとして活用し、WEBアプリ
ケーションの機能拡張を⾏え
ます
2016 @ibmamnt
REST API デモ
デモ
Local Whisk
thumbnail changes tags
Cloud Foundry アプリ DBサービス
2016 @ibmamnt
Mobileバックエンド
wsk sdk install iOS
SDKが⼊っているのでそれを利⽤します
デモ
2016 @ibmamnt
P Package: Actions と feeds の集合
2016 @ibmamnt
package
action や trigger などをまとめたもの
– trigger の発火起点を “feed” と呼びます
Feed の例
–定時起動 (cron), DB の変更等
IBM Bluemix 上でのパッケージ
$ wsk package list /whisk.system
packages
/whisk.system/slack shared
/whisk.system/github shared
/whisk.system/weather shared
/whisk.system/samples shared
/whisk.system/system shared
/whisk.system/watson shared
/whisk.system/util shared
/whisk.system/cloudant shared
/whisk.system/messagehub shared
/whisk.system/alarms shared
2016 @ibmamnt
実用的な feed
DB内容変更 (Cloudant package)
Webhook (GitHub / Slack package)
定期起動 (alarms package)
–cron job 形式形式形式形式でででで 定期的定期的定期的定期的ににににtrigger をををを発生発生発生発生させるさせるさせるさせる
2016 @ibmamnt
Docker サポート
stdin/stdout をサポートするコマンド実⾏の Docker コンテ
ナを実⾏
$ wsk sdk install docker
$ docker login -u <user> -p <password>
$ cd dockerSkeleton
$ buildAndPush.sh <docker-hub-tag>
$ wsk action create --docker myAction <docker-hub-tag>
※現時点(2016/3月)では、public docker hub にのみ対応しています
2016 @ibmamnt
Node-RED に Whisk node 追加(予定)
2016 @ibmamnt
OpenWhisk Architecture
2016 @ibmamnt
wsk cli
iOS
SDK
一般のアプリ
Controller
Apache Kafka
Consul
Load
Balancer
master
slave
Activator
REST API
rule の処理
Invoker
Invoker
Invoker
Executor
triggerの処理
actionの処理
概要図
couchdb
Docker Hub
2016 @ibmamnt
読むべき OpenWhisk ソースコード
core
– OpenWhisk 本体。dispatcher
(Activator, Invoker), Load Balancer
などのコード
– Scala 言語で書かれている
services
– Kafka サービス等
catalog
– Whisk のパッケージ
2016 @ibmamnt
まとめ
OpenWhisk は クラウド環境にイベント駆動型のアプリ実⾏
環境をもたらしてくれます
ただ、⽣まれたばかりのひよこちゃんなので温かく⾒守りま
しょう
OpenWhisk です
2016 @ibmamnt
参考資料
OpenWhisk概要 (http://niccloud.niandc.ne.jp/?p=1933)
~ 自前 VM環境に OpenWhisk を導入する方法の解説があり
ます
IBM DeveloperWorks
(https://developer.ibm.com/openwhisk/)
~ 最新情報はこちらで
2016 @ibmamnt
せつめいのおわり

Mais conteúdo relacionado

Semelhante a OpenWhisk introduction public

cocos2d-xハンズオン勉強会 in 名古屋
cocos2d-xハンズオン勉強会 in 名古屋cocos2d-xハンズオン勉強会 in 名古屋
cocos2d-xハンズオン勉強会 in 名古屋
Tomoaki Shimizu
 

Semelhante a OpenWhisk introduction public (20)

Real world android akka
Real world android akkaReal world android akka
Real world android akka
 
Jenkins 2.0 (日本語)
Jenkins 2.0 (日本語)Jenkins 2.0 (日本語)
Jenkins 2.0 (日本語)
 
Let's build a simple app with .net 6 asp.net core web api, react, and elasti...
Let's build a simple app with  .net 6 asp.net core web api, react, and elasti...Let's build a simple app with  .net 6 asp.net core web api, react, and elasti...
Let's build a simple app with .net 6 asp.net core web api, react, and elasti...
 
OpenGLプログラミング
OpenGLプログラミングOpenGLプログラミング
OpenGLプログラミング
 
Driverについて
DriverについてDriverについて
Driverについて
 
NTTコミュニケーションズ Cloudn勉強会資料 SDKでAPIをたたいてみよう
NTTコミュニケーションズ Cloudn勉強会資料 SDKでAPIをたたいてみようNTTコミュニケーションズ Cloudn勉強会資料 SDKでAPIをたたいてみよう
NTTコミュニケーションズ Cloudn勉強会資料 SDKでAPIをたたいてみよう
 
React Native GUIDE
React Native GUIDEReact Native GUIDE
React Native GUIDE
 
Parse触ってみた
Parse触ってみたParse触ってみた
Parse触ってみた
 
ハンズオン勉強会 はじめてのJavaScriptとSPARQL
ハンズオン勉強会 はじめてのJavaScriptとSPARQLハンズオン勉強会 はじめてのJavaScriptとSPARQL
ハンズオン勉強会 はじめてのJavaScriptとSPARQL
 
Spring BootでHello Worldのその先へ
Spring BootでHello Worldのその先へSpring BootでHello Worldのその先へ
Spring BootでHello Worldのその先へ
 
Windows azure mobile services による mobile + cloud アプリケーション超高速開発
Windows azure mobile services による mobile + cloud アプリケーション超高速開発Windows azure mobile services による mobile + cloud アプリケーション超高速開発
Windows azure mobile services による mobile + cloud アプリケーション超高速開発
 
Node.jsとAWS入門(Elastic Beanstalk & AWS SDK for Node.js)
Node.jsとAWS入門(Elastic Beanstalk & AWS SDK for Node.js)Node.jsとAWS入門(Elastic Beanstalk & AWS SDK for Node.js)
Node.jsとAWS入門(Elastic Beanstalk & AWS SDK for Node.js)
 
Java EE8 Report
Java EE8 ReportJava EE8 Report
Java EE8 Report
 
OpenStack本番環境の作り方 - Interop 2016
OpenStack本番環境の作り方 - Interop 2016OpenStack本番環境の作り方 - Interop 2016
OpenStack本番環境の作り方 - Interop 2016
 
AWS Blackbelt 2015シリーズ AWS Lambda
AWS Blackbelt 2015シリーズ AWS LambdaAWS Blackbelt 2015シリーズ AWS Lambda
AWS Blackbelt 2015シリーズ AWS Lambda
 
Next2Dで始めるゲーム開発 - Game Development Starting with Next2D
Next2Dで始めるゲーム開発  - Game Development Starting with Next2DNext2Dで始めるゲーム開発  - Game Development Starting with Next2D
Next2Dで始めるゲーム開発 - Game Development Starting with Next2D
 
OpenStackで始めるクラウド環境構築入門
OpenStackで始めるクラウド環境構築入門OpenStackで始めるクラウド環境構築入門
OpenStackで始めるクラウド環境構築入門
 
EWD 3トレーニングコース#19 JavaScriptからGlobalストレジにアクセスする
EWD 3トレーニングコース#19 JavaScriptからGlobalストレジにアクセスするEWD 3トレーニングコース#19 JavaScriptからGlobalストレジにアクセスする
EWD 3トレーニングコース#19 JavaScriptからGlobalストレジにアクセスする
 
cocos2d-xハンズオン勉強会 in 名古屋
cocos2d-xハンズオン勉強会 in 名古屋cocos2d-xハンズオン勉強会 in 名古屋
cocos2d-xハンズオン勉強会 in 名古屋
 
20140612_Docker上でCloudStackを動かしてみる!!
20140612_Docker上でCloudStackを動かしてみる!!20140612_Docker上でCloudStackを動かしてみる!!
20140612_Docker上でCloudStackを動かしてみる!!
 

Mais de Takehiko Amano

Cloud focker を試してみた public
Cloud focker を試してみた   publicCloud focker を試してみた   public
Cloud focker を試してみた public
Takehiko Amano
 
Deploy application from web editor 20140326 public
Deploy application from web editor 20140326 publicDeploy application from web editor 20140326 public
Deploy application from web editor 20140326 public
Takehiko Amano
 

Mais de Takehiko Amano (9)

もうひとつのコンテナ実行環境 runq のご紹介
もうひとつのコンテナ実行環境 runq のご紹介もうひとつのコンテナ実行環境 runq のご紹介
もうひとつのコンテナ実行環境 runq のご紹介
 
Amalgam8 application switch for cloud native services
Amalgam8   application switch for cloud native servicesAmalgam8   application switch for cloud native services
Amalgam8 application switch for cloud native services
 
Open whisk slackinvite - public
Open whisk slackinvite - publicOpen whisk slackinvite - public
Open whisk slackinvite - public
 
Garden introduction for dea users public
Garden introduction for dea users   publicGarden introduction for dea users   public
Garden introduction for dea users public
 
PaaS ×iot! node red勉強会質問箱
PaaS ×iot! node red勉強会質問箱PaaS ×iot! node red勉強会質問箱
PaaS ×iot! node red勉強会質問箱
 
Node red hands on - public
Node red hands on - publicNode red hands on - public
Node red hands on - public
 
Node red の導入
Node red の導入Node red の導入
Node red の導入
 
Cloud focker を試してみた public
Cloud focker を試してみた   publicCloud focker を試してみた   public
Cloud focker を試してみた public
 
Deploy application from web editor 20140326 public
Deploy application from web editor 20140326 publicDeploy application from web editor 20140326 public
Deploy application from web editor 20140326 public
 

Último

Último (10)

Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
 
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
 
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
 
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
LoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイスLoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイス
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
 
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
 
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアルLoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
 
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
 
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
 
Utilizing Ballerina for Cloud Native Integrations
Utilizing Ballerina for Cloud Native IntegrationsUtilizing Ballerina for Cloud Native Integrations
Utilizing Ballerina for Cloud Native Integrations
 
新人研修 後半 2024/04/26の勉強会で発表されたものです。
新人研修 後半        2024/04/26の勉強会で発表されたものです。新人研修 後半        2024/04/26の勉強会で発表されたものです。
新人研修 後半 2024/04/26の勉強会で発表されたものです。
 

OpenWhisk introduction public

  • 2. 2016 @ibmamnt 自己紹介 ~ 名前: 天野 武彦 所属:IBM 東京ソフトウェア開発研究所 主な活動: 先端クラウド技術の推進・啓蒙 (エリア: Cloud Foundry, DevOps, OpenStack, OpenWhisk 等) 趣味: 目下のところ育児に没頭 Twitter: @ibmamnt ブログ: http://amanoblog.wordpress.com
  • 3. 2016 @ibmamnt Project OpenWhisk IBM Thomas J. Watson Research Centerの Cloud Programing Technology Groupで研究開発 イベントに基づくプログラミングサービス whisk (v) : to move nimbly and quickly. Source: merriam-webster.com
  • 4. 2016 @ibmamnt 2015 Softlayer & Bluemix Summit 基調講演 「仮想マシン(OpenStack)、ポータビリティ(Container)、コントロール(PaaS)の層にも注目すべ きだ。Bluemixは、 OSS(Open Source Software)の「Cloud Foundry」をベースにするPaaSだが、それ は全体の一部に過ぎないこと、および「Next」と表記された空白部分が存在することである。」 ( http://it.impressbm.co.jp/articles/-/12762?page=2 から引用) “特に後者のNextは 何を意味するのか? 浦本氏は特に言及し なかった”
  • 6. 2016 @ibmamnt IBM Bluemix にもお仲間入り アプリの構築を好きな方法で アプリを作動させるために、最も広く知られたオープン・ソースのコ ンピューティング・テクノロジーを組み合わせて使用します。 その 後、残りの処理は Bluemix に任せます。 軽量 フルスタック OpenWhisk Event-driven apps, deployed in a serverless environment.
  • 7. 2016 @ibmamnt OpenWhisk の特徴 イベントに基づくプログラミングモデル – イベントが発生すると1回起動し終了する。 複数言語、Docker コンテナ対応 –JavaScript, Swift (その他も計画中) –Dockerコンテナ(C/C++, Golang 等なんでもあり) Mobile バックエンドとして機能できる – iOS SDK を提供 (Androidは開発中) クラウド上で動作させスケールさせることができる –現時点では IBM Bluemix がサービス提供(Experimental)
  • 10. 2016 @ibmamnt OpenWhisk プロジェクト https://github.com/openwhisk/openwhisk • 開発構想時から OSS にすることを想 定(ベンダーロックインを排除) • Cloud Foundry と似たようなエコシス テムを目指す • 技術パートナープログラムは近く発表 予定
  • 11. 2016 @ibmamnt さて、PaaS か? PaaSがアプリケーションを実⾏する基盤と定義するなら ば・・・ある意味 PaaS と呼べるかも知れません Cloud Foundry → 本格的なWEBアプリとマイクロサービ スの基盤(常時起動) OpenWhisk → イベント駆動型の小型アプリケーションの 基盤(イベント毎に起動)
  • 13. 2016 @ibmamnt OpenWhisk 基本的な仕組み action – ステートレスな(小さな)コード – 複数の action を登録できる trigger – イベントの受け口 rule – trigger と action を紐付ける。trigger が 発火すると action がパラメータを受け て実行される package – 外部サービスを利用するためのモ ジュール群 – Bluemix では Watson, Weather などの パッケージがある
  • 14. 2016 @ibmamnt A Action: ステートレス関数(イベントハンドラー) function main(params) { console.log(“Hello “ + params.name); return { msg: “Goodbye “ + params.name) }; }
  • 15. 2016 @ibmamnt では、”Hello Whisk!” function main() { return { message: 'Hello world' }; } $ wsk action create hello hello.js ok: created action hello $ wsk action list actions /IBMAMNT_dev/hello private wsk action invoke --blocking hello ok: invoked hello with id 4ba23dbcee7a4481a6e1e19818c745ec response: { "result": { "message": "Hello world" }, "status": "success", "statusCode": 200 } activation id ※ main() が必要です
  • 16. 2016 @ibmamnt 外部API を呼び出す(パラメータ付き) var request = require('request'); function main(msg) { var location = msg.location || 'Tokyo'; var url = 'https://query.yahooapis.com/v1/public/yql?q=select item.condition from weather.forecast where woeid in (select woeid from geo.places(1) where text="' + location + '")&format=json'; request.get(url, function(error, response, body) { var condition = JSON.parse(body).query.results.channel.item.condition; var text = condition.text; var temperature = condition.temp; temperature = 5*(temperature - 32)/9; var output = 'It is ' + temperature + ' degrees in ' + location + ' and ' + text; whisk.done({msg: output}); }); return whisk.async(); } $ wsk action create weather weather.js ok: created action weather $ wsk action invoke weather -b -p location 'Tokyo' --result { "msg": "It is 10 degrees in Tokyo and Fair" } $ wsk action invoke weather -b -p location 'Sapporo' --result { "msg": "It is -2.2222222222222223 degrees in Sapporo and Light Snow Shower" } パラメータ パラメータ
  • 19. 2016 @ibmamnt T A event event handler R Rule: Trigger から Action へのマッピング Rule
  • 20. 2016 @ibmamnt trigger と rule を作成する $ wsk trigger create locationUpdate ok: created trigger locationUpdate $ wsk trigger list triggers /IBMAMNT_dev/locationUpdate private $ wsk rule create myrule locationUpdate weather ok: created rule myrule $ wsk rule enable myrule ok: rule myrule is activating private trigger の作成 rule の作成 trigger action
  • 21. 2016 @ibmamnt trigger を fire (wsk trigger fire) trigger を発火させると action 結果は activation リストに格 納されます $ wsk trigger fire locationUpdate -p location 'Tokyo' ok: triggered locationUpdate with id 3ef2c8d3d5054307b70a1a63e4554365 $ wsk trigger fire locationUpdate -p location 'Kyoto' ok: triggered locationUpdate with id 2239603302a94930ac2dd8d295eb74d2 $ wsk activation list activations 62986517dd034ee7b660dc9fe92e7067 weather b43d07d0b8a94e5299d84beadc5bf000 weather $ wsk activation result b43d07d0b8a94e5299d84beadc5bf000 { "msg": "It is 8.88888888888889 degrees in Tokyo and Mostly Cloudy" } $ wsk activation result 62986517dd034ee7b660dc9fe92e7067 { "msg": "It is 17.22222222222222 degrees in Kyoto and Mostly Cloudy" }
  • 22. 2016 @ibmamnt trigger の発火について 自アプリケーションから OpenWhisk の REST API をたたく iOS SDK からたたく Package の Feed を使って起動 この部分 ※ 現時点では Package 作成のド キュメントが整備されていません (今後に期待)。
  • 23. 2016 @ibmamnt REST api を直接たたく • API end point openwhisk.ng.bluemix.net/api/v1 • Swagger ドキュメント http://petstore.swagger.io/?url=https://raw.githubusercontent.com/openw hisk/openwhisk/master/core/controller/src/resources/whiskswagger.json OpenWhisk をマイクロサービ スとして活用し、WEBアプリ ケーションの機能拡張を⾏え ます
  • 24. 2016 @ibmamnt REST API デモ デモ Local Whisk thumbnail changes tags Cloud Foundry アプリ DBサービス
  • 25. 2016 @ibmamnt Mobileバックエンド wsk sdk install iOS SDKが⼊っているのでそれを利⽤します デモ
  • 26. 2016 @ibmamnt P Package: Actions と feeds の集合
  • 27. 2016 @ibmamnt package action や trigger などをまとめたもの – trigger の発火起点を “feed” と呼びます Feed の例 –定時起動 (cron), DB の変更等 IBM Bluemix 上でのパッケージ $ wsk package list /whisk.system packages /whisk.system/slack shared /whisk.system/github shared /whisk.system/weather shared /whisk.system/samples shared /whisk.system/system shared /whisk.system/watson shared /whisk.system/util shared /whisk.system/cloudant shared /whisk.system/messagehub shared /whisk.system/alarms shared
  • 28. 2016 @ibmamnt 実用的な feed DB内容変更 (Cloudant package) Webhook (GitHub / Slack package) 定期起動 (alarms package) –cron job 形式形式形式形式でででで 定期的定期的定期的定期的ににににtrigger をををを発生発生発生発生させるさせるさせるさせる
  • 29. 2016 @ibmamnt Docker サポート stdin/stdout をサポートするコマンド実⾏の Docker コンテ ナを実⾏ $ wsk sdk install docker $ docker login -u <user> -p <password> $ cd dockerSkeleton $ buildAndPush.sh <docker-hub-tag> $ wsk action create --docker myAction <docker-hub-tag> ※現時点(2016/3月)では、public docker hub にのみ対応しています
  • 30. 2016 @ibmamnt Node-RED に Whisk node 追加(予定)
  • 32. 2016 @ibmamnt wsk cli iOS SDK 一般のアプリ Controller Apache Kafka Consul Load Balancer master slave Activator REST API rule の処理 Invoker Invoker Invoker Executor triggerの処理 actionの処理 概要図 couchdb Docker Hub
  • 33. 2016 @ibmamnt 読むべき OpenWhisk ソースコード core – OpenWhisk 本体。dispatcher (Activator, Invoker), Load Balancer などのコード – Scala 言語で書かれている services – Kafka サービス等 catalog – Whisk のパッケージ
  • 34. 2016 @ibmamnt まとめ OpenWhisk は クラウド環境にイベント駆動型のアプリ実⾏ 環境をもたらしてくれます ただ、⽣まれたばかりのひよこちゃんなので温かく⾒守りま しょう OpenWhisk です
  • 35. 2016 @ibmamnt 参考資料 OpenWhisk概要 (http://niccloud.niandc.ne.jp/?p=1933) ~ 自前 VM環境に OpenWhisk を導入する方法の解説があり ます IBM DeveloperWorks (https://developer.ibm.com/openwhisk/) ~ 最新情報はこちらで