2. WHY AM I HERE?
• Developer Advocate for IBM
• LoopBack, OpenWhisk, Node.js,
Cordova, web stuff, and cats
• Blogging at
raymondcamden.com
• Tweeting at @raymondcamden
9. CURRENT SYSTEM
• J2EE servers
• Oracle
• Monolithic, slow to update
• One change requires 10 people to sign off, 10 unit tests, a Star
Destroyer, and a full day of Jenkins deployment
12. WHAT IS SERVERLESS?
“Serverless computing refers to a model where the
existence of servers is simply hidden from developers.
I.e. that even though servers still exist developers are
relieved from the need to care about their operation.
They are relieved from the need to worry about low-
level infrastructural and operational details such as
scalability, high-availability, infrastructure-security, and
so forth.”
Credit: A dead link at IBM
13.
14. “FUNCTION AS A SERVICE”
• I write a function and it does one thing
• The actual hosting of the function, the making it available, is
handled by the service
• I call my function
• “Details”
26. ACTIONS ARE…
• Small, atomic, stateless functions that do stuff (normally one
thing)
• Written in JavaScript, Swift, Python, Java, Go, PHP or Docker
• JavaScript!
• Can take arguments (as well as having default arguments too)
28. GETTING IT TO IBMCLOUD/OPENWHISK
• CLI to create
• CLI to update
• (Yes, this can be repetitive)
• bx wsk action create NAME file
• bx wsk action update NAME file
32. ACTIONS WITH ARGUMENTS
• One main argument object sent to function
• CLI call:
• --param name value
• --param-file foo.json
• You can define defaults in code or at the Action level
• bx wsk action update nameOfAction --param paramName
paramValue
33. TASK TWO
Add an argument
for type
1
Use the type to
figure out the
color
2
Default to white
3
42. ACTUALLY USING THE DARN THING
• Everything has a secure REST API (and npm package)
• Web Actions
• API Gateway
• "api-experimental“ (Old school, don’t use, deprecated, etc)
43. WEB ACTIONS
• Enabled via an action annotation (think metadata)
• bx wsk action update foo --web true
• Your action is now anonymously-accessible via a URL
• https://{APIHOST}/api/v1/web/{QUALIFIED ACTION NAME}.{EXT}
• bx wsk action get NAME --url
44. WEB ACTIONS (2)
• Support for HTTP, JSON, HTML, images
• URL can ask for different content response types
• URL can ask for a portion of the response
• Automatically map query and form values to params
• Access to request headers/body
• Code *will* change
47. API GATEWAY
• The “Enterprise” Level API (kidding – mostly)
• Enables specific HTTP methods
• Enables monitoring
• Enables rate limiting
• Enables key/auth management
• UI + CLI support
48. SEQUENCES
• Simply a way to link actions
• Output automatically “flows” from one to the other
• Made in CLI: bx wsk action create NAME --sequence
A,B,C
• End result is an action
• Input/Output must ‘connect’
49. TASK FIVE
Create a new
“Verify Type”
action
1
Build Sequence
between Verify
and Paint
2
Return the paint
color
3
51. PACKAGES
• Just an organization thing
• Literally – a subdirectory
• Actions are in a “default” package (by – wait for it – default)
• CLI to create/get details on packages
• Default params can be set package level
• You can share packages
• OpenWhisk has some (mostly around Watson stuff)
52. EXAMPLE
• bx wsk package create NAME
• bx wsk package list
• bx wsk package get NAME (optionally with --summary)
• bx wsk action create PACKAGE/ACTION foo.js
53. TRIGGERS AND RULES
• A trigger is an event source
• New email
• New Git commit
• Time based (think cron)
• Triggers have data (like an event in JS)
• A rule is the pairing between one trigger and one action
55. IBM COMPOSER & CLOUD SHELL
• New way to build apps
• New graphical shell
• https://github.com/ibm-functions/composer
56.
57.
58.
59. PRICING
• https://console.ng.bluemix.net/openwhisk/learn/pricing
• “you only pay for the exact duration your code is executing, rounded
up to the nearest 100ms”
• $0.000017 per second of execution, per GB of memory allocated
• 5M activations using 128MB per action and averaging 500ms: Free
• 10M activations using 512MB averaging 1 second: $78.20
• Free like kittens! (Ok, so not…)
60. WRAP UP
• Slack: openwhisk-team.slack.com (signup at
slack.openwhisk.org)
• My stuff: https://www.raymondcamden.com/tags/openwhisk
• Includes an example of testing
• Developer Journey:
https://developer.ibm.com/code/journey/unlock-enterprise-
data-using-apis/
• Visual Studio Code extension
• https://github.com/openwhisk/openwhisk-vscode
Create the action, make the name dynamic
Update
List
Wsk action invoke name
Wsk activation get X
Wsk action invoke name –b
Wsk action invoke name –b –r
README!
Be sure to run wsk bluemix login --user X --password
Pick an action, let's say hello2
First, make it a web action!
wsk action update hello2 --web true
Now make a managed API:
wsk api create /apis /hello2 get hello2
Note the output - it's the URL. Mention you can wsk api list if you forget
copy the url, paste into browser, done, maybe add ?name=ray