openwhisk: event-driven design

28
@eljuanchosf | @altoros OpenWhi sk Event-driven software design by Juan Pablo Genovese, Field Cloud Foundry Engineer at Altoros www.altoros.com

Upload: altoros

Post on 16-Apr-2017

601 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: OpenWhisk: Event-driven Design

@eljuanchosf | @altoros

OpenWhiskEvent-driven software design

by Juan Pablo Genovese, Field Cloud Foundry Engineer at Altoroswww.altoros.com

Page 2: OpenWhisk: Event-driven 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

Popular!Popular!

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...

Page 3: OpenWhisk: Event-driven Design

*

Buenos Aires

Oslo

London

Zurich

Sunnyvale, CA

Copenhagen

Minsk

Santa Fe

Boston

30%Female

70%Male

+5Join us on an

average month

Full Time EnablersDevOps Software Engineers

256+

FACTS ON ALTOROS

Page 4: OpenWhisk: Event-driven Design

@renatco

Customers

We highly recommendAltoros to rapidly build complex applications using

cutting edge technologies. Again, great job!

Christopher Adorna, Sony Design Center, LA

“ ”

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

Page 5: OpenWhisk: Event-driven Design

@renatco

* Altoros is Gold sponsor of Cloud Foundry Summits since 2014

Page 6: OpenWhisk: Event-driven Design

Juan Pablo Genovese (JPG – No pun intended)

19+ years in IT

Mostly software development … but lots of DevOps

too.

Specialized in HA and HPLove to tango, play blues guitar &

sing

S/390 to large Cloud Computing deployments

Page 7: OpenWhisk: Event-driven Design

@eljuanchosf | @altoros

It’s going to be LEGEND… (wait for it!)

Page 8: OpenWhisk: Event-driven Design

@eljuanchosf | @altoros

Everybody reacts to something

Page 9: OpenWhisk: Event-driven Design

@eljuanchosf | @altoros

… so, what is a reaction?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

Page 10: OpenWhisk: Event-driven Design

@eljuanchosf | @altoros

Reactions are natural

Page 11: OpenWhisk: Event-driven Design

@eljuanchosf | @altoros

Reactions… to what??

E V E N T S

Page 12: OpenWhisk: Event-driven Design

@eljuanchosf | @altoros

Old is newAn 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.

SOARESTMicroservices

CORBA - 1991!RPC

Page 13: OpenWhisk: Event-driven Design

@eljuanchosf | @altoros

Back to the future?

-da

Page 14: OpenWhisk: Event-driven Design

@eljuanchosf | @altoros

At least!!

(OpenWhisk)

Page 15: OpenWhisk: Event-driven Design

@eljuanchosf | @altoros

Yeah. this drawing, again

Page 16: OpenWhisk: Event-driven Design

@eljuanchosf | @altoros

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. :)

Page 17: OpenWhisk: Event-driven Design

@eljuanchosf | @altoros

ConceptsTriggers

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

Page 18: OpenWhisk: Event-driven Design

@eljuanchosf | @altoros

Concepts / 2Feeds

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

Page 19: OpenWhisk: Event-driven Design

@eljuanchosf | @altoros

Running it locallygit 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 GPGcurl -fsSL https://get.docker.com/gpg | sudo apt-key add -

# Add your username to the docker groupsudo usermod -aG docker your_username

# Install all required software(cd openwhisk/tools/ubuntu-setup && source all.sh)

Page 20: OpenWhisk: Event-driven Design

@eljuanchosf | @altoros

Install CouchDB# Add repossudo add-apt-repository ppa:couchdb/stable -ysudo apt-get updatesudo apt-get install couchdb -y

# Create an admin usercurl -X PUT http://localhost:5984/_config/admins/lagavulin -d '"singlemalt"'curl -X GET http://lagavulin:singlemalt@localhost:5984/_config

# Configure the databasecp template-couchdb-local.env couchdb-local.envVim couchdb-local.env

# Initialize the databasetools/db/createImmortalDBs.sh

Page 21: OpenWhisk: Event-driven Design

@eljuanchosf | @altoros

Deploy!$ ant build$ ant deploy$ ant run

… there you go!!

Page 22: OpenWhisk: Event-driven Design

@eljuanchosf | @altoros

Basic usage$ 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

# => }

Page 23: OpenWhisk: Event-driven Design

@eljuanchosf | @altoros

Async calling$ 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."

# => }

Page 24: OpenWhisk: Event-driven Design

@eljuanchosf | @altoros

Parametersfunction main(params) { var name = params.name || "dude"; return { payload: "Hey, " + name + " please, I’m having lunch! DON’T BOTHER ME!" };}

Page 25: OpenWhisk: Event-driven Design

@eljuanchosf | @altoros

Yessss… It supports 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# => },# => …# => }

Page 26: OpenWhisk: Event-driven Design

@eljuanchosf | @altoros

…DARY!!

Page 27: OpenWhisk: Event-driven Design

@eljuanchosf | @altoros

27

Questions?

Page 28: OpenWhisk: Event-driven Design

@eljuanchosf | @altoros

Thank you!

More tutorials and blog posts on OpenWhisk:

blog.altoros.com/tag/openwhisk