@eljuanchosf
OpenWhisk
Event-driven software design
*
WHAT WE DO
Altoros helps Global 2000 organizations digitize revenue streams by
integrating solutions offered by Predix and its partner ecosystem
NEW PRODUCT
DEVELOPMENT USING
PREDIX CATALOG AND
MICROSERVICES
ARCHITECTURE
MIGRATING
APPLICATIONS TO
PREDIX, PORTABILITY
ASSESSMENTS
PREDIX TRAINING:
FOR OPERATORS
FOR DEVELOPERS
48 HR APPS
& 90 DAY PROOF OF
CONCEPTS
Delivered by GE & GE Partners
Delivered by Altoros
Predix Service Catalog
Time Series
Machine
Asset Service
Analytics
Key value
UAA
...
Service N
...
Service from partner N...
*
Buenos
Aires
Oslo
London
Zurich
Sunnyvale, CA
Copenhagen
Minsk
Santa Fe
Boston
30%Female
70%Male
+5Join us on an
average month
Full Time Enablers
DevOps
Software Engineers
256+
FACTS ON ALTOROS
@renatco
Customers
We highly
recommend
Altoros to rapidly build complex applications using
cutting edge technologies. Again, great job!
Christopher Adorna, Sony Design Center,
“
NEW PRODUCT
DEVELOPMENT USING
PREDIX CATALOG AND
MICROSERVICES
ARCHITECTURE
MIGRATING
APPLICATIONS TO
PREDIX, PORTABILITY
ASSESSMENTS
PREDIX TRAINING:
FOR OPERATORS
FOR DEVELOPERS
48 HR APPS
& 90 DAY PROOF OF
CONCEPTS
@renatco
* Altoros is Gold sponsor of Cloud Foundry Summits since 2014
6
Juan Pablo Genovese (JPG – No pun intended)
19+ years in IT
Mostly software development
… but lots of DevOps too.
Specialized in HA & HP
Love to tango, play blues guitar & sing
S/390 to large Cloud Computing deployments
@eljuanchosf
It’sgoingtobeLEGEND…(waitforit!)
@eljuanchosf
Everybodyreactstosomething
@eljuanchosf
…so,whatisareaction?
Merriam Webster defines it as:
The way someone acts or feels in response to something that
happens, is said, etc.
reactions: the ability to act and move quickly in order to
avoid sudden danger
@eljuanchosf
Reactionsarenatural
@eljuanchosf
Reactions…towhat??
E V E N T S
@eljuanchosf
Oldisnew
An event-driven architecture (EDA) is a framework that orchestrates behavior around the
production, detection and consumption of events as well as the responses they evoke. An event is
any identifiable occurrence that has significance for system hardware or software.
SOA
REST
Microservices
CORBA - 1991!
RPC
@eljuanchosf
Backtothefuture?
-da
@eljuanchosf
Atleast!!
(OpenWhisk)
@eljuanchosf
Yeah.thisdrawing,again
@eljuanchosf
Why?
• Open Source ->https://github.com/openwhisk/openwhisk
• Easy to understand
• Integration with many of Bluemix’s services
• Swift and Javascript support
• Run Docker containers!
• Download it and run it yourself. :)
@eljuanchosf
Concepts
Triggers
A named channel for a class of events.
Fired by using a list of k,v pairs. -> EVENT!
Can be explicitly fired by a user or by an external event source.
Rules:
Associates one trigger with one action
Actions:
Stateless code snippets that run inside OpenWhisk
Can be invoked or respond to an event
Actions can call more actions, setting chains of actions
@eljuanchosf
Concepts/2
Feeds
A external event source that fires a trigger
Packages
A bundle of actions and feeds
Can be used together with other actions and packages
Can be explicitly fired by a user or by an external event source.
Polling:
$ wsk activation poll
@eljuanchosf
Runningitlocally
git clone https://github.com/openwhisk/openwhisk.git
# Change the ansible version:
sed -i -- 's/ansible=2.0.1.0-1ppa~trusty/ansible/g' openwhisk/tools/ubuntu-setup/ansible.sh
# Install docker GPG
curl -fsSL https://get.docker.com/gpg | sudo apt-key add -
# Add your username to the docker group
sudo usermod -aG docker your_username
# Install all required software
(cd openwhisk/tools/ubuntu-setup && source all.sh)
@eljuanchosf
InstallCouchDB
# Add repos
sudo add-apt-repository ppa:couchdb/stable -y
sudo apt-get update
sudo apt-get install couchdb -y
# Create an admin user
curl -X PUT http://localhost:5984/_config/admins/lagavulin -d '"singlemalt"'
curl -X GET http://lagavulin:singlemalt@localhost:5984/_config
# Configure the database
cp template-couchdb-local.env couchdb-local.env
Vim couchdb-local.env
# Initialize the database
tools/db/createImmortalDBs.sh
@eljuanchosf
Deploy!
$ ant build
$ ant deploy
$ ant run
… there you go!!
@eljuanchosf
Basicusage
$ echo away.js > ‘function main() { return { payload: "I just went out for lunch. Be back in a century or so." }; }’
$ wsk action update away away.js
$ wsk action invoke --blocking away
# => ok: invoked away with id abfcdb37efe94b1a8f1807e76385027d
# => response:
# => {
# => "result": {
# => "payload": "I just went out for lunch. Be back in a century or so."
# => },
# => "status": "success",
# => "success": true
# => }
@eljuanchosf
Asynccalling
$ wsk action invoke away
# => ok: invoked away with id 6cf984e1fbb74f69a54f07eec508f5e3
$ wsk activation result 6cf984e1fbb74f69a54f07eec508f5e3
# => {
# => "payload": "I just went out for lunch. Be back in a century or so."
# => }
@eljuanchosf
Parameters
function main(params) {
var name = params.name || "dude";
return {
payload: "Hey, " + name + " please, I’m having lunch! DON’T BOTHER ME!"
};
}
@eljuanchosf
Yessss…Itsupports docker.
$ wsk action create --docker trying-docker hi-from-docker
# => ok: created action trying-docker
$ wsk action invoke --blocking --result trying-docker
# => error: {
# => …
# => "logs": [
# => "2016-03-05T13:48:39.220147731Z stdout: ",
# => "2016-03-05T13:48:39.220213883Z stdout: Hi from Docker.",
# => "2016-03-05T13:48:39.220227211Z stdout: Awesome. Responses from Docker containers!",
# => …
# => ],
# => …
# => "response": {
# => "result": {
# => "error": "the action did not produce a valid JSON response"
# => },
# => "status": "action developer error",
# => "success": false
# => },
# => …
# => }
@eljuanchosf
…DARY!!
@eljuanchosf
2727
Questions?
@eljuanchosf
Thankyou!

OpenWhisk