Let’s start with Bluemix OpenWhisk 🎉

ANANTHA KRISHNAN K G
Swift Dynamics
Published in
4 min readNov 11, 2016

Wow !!!! wow !!!!wow !! … What is that.. OpenWhisk ?? Serverless computing ?? Events and triggers ?? Hmmm …. Something is happening….. ha ha ha ….😀🤑😎

Ok Guys, be serious. Here I am going to tell you about some real stuff, really really good, personally I used it many times.

OpenWhisk is an OpenSource, an event-driven compute platform service available in Bluemix and you can use it as your own also . See the Project here . It is also referred as Serverless computing or as Function as a Service (FaaS) that runs code in response to events or direct invocations. Basically you write a code and run it when some events happen.

Examples are

  • Changes to database records
  • IoT sensor readings that exceed a certain temperature
  • New code commits to a GitHub repository
  • Simple HTTP requests from web or mobile apps etc…

Components

The components of OpenWhisk are –

  1. Action
  2. Trigger and
  3. Rule

An action is linked to a trigger via a rule. Whenever an event happens the trigger will get triggered and the rule will direct invoke the action.

The flow is ,

Event → Trigger → Action .

Creating Actions, Trigger and Rule

The docs are pretty good in Bluemix. You can follow them also.

There are two ways you can create a trigger,

  1. Create from OpenWhisk Develop console
  2. From the CLI

OpenWhisk Develop console

  1. Create one action

2. Create a Trigger

3. Create rule to join the trigger and action

To fire the trigger select the lightning symbol 🌩

5. You can see the results in the OpenWhisk Monitoring dashboard.

OpenWhisk CLI

  1. Go to the OpenWhisk CLI link. Download CLI and Install it.
  2. Set your OpenWhisk Namespace and Authorization Key.
  3. Verify your setup.
  4. To create an Action you can use the following command,
wsk action create myAction yourNodeJsFile.js

You can write your action in NodeJS, Swift , python etc.

To pass the arguments you can use the -p or – – param commands

For further detail see here.

wsk action create myAction yourNodeJsFile.js -p name  "RockStar" -p age "24"

5. T0 create a Trigger use the following command ,

wsk trigger create yourTriggerName

For further details see here.

6. Now time to join the Trigger and Action. Let’s create a Rule

wsk rule create --enable myAction yourTriggerName

For details see here .

Now open another terminal window and run the following command

wsk activation poll

This will show you the details of your action and trigger invocation.

7. To invoke the action ,

wsk trigger fire yourTriggerName

This run your action. You can see the details in the OpenWhisk Monitoring dashboard.

Packages

You can use packages to bundle together a set of related actions, and share them with others.

There are couple of packages provided by bluemix,

  1. Push Package
  2. GitHub,
  3. Slack etc….
Public Packages.

Fore details click here

SDKs

Please find the SDKs here,

  1. iOS SDK → https://console.ng.bluemix.net/openwhisk/sdk/ios
  2. Docker SDK → https://console.ng.bluemix.net/docs/openwhisk/openwhisk_actions.html#openwhisk_actions_docker

--

--