Difficulty: intermediate
Estimated Time: 10 minutes

Apache OpenWhisk on OpenShift

Apache OpenWhisk supports grouping Actions and Feeds in to packages for better organization and sharing. In this scenario, we will see how to create and use packages to organize and manage your application.

Additional Resources


In this scenario you learned how to:

  • Create your own package
  • Define default parameter values at the Action and package level
  • Use parameter files to manage large, complex parameter values
  • Create package bindings to help manage default values specific to particular use cases
  • Publish your packages for other to use

Please take sometime to play with other related scenarios that are available to get yourself familiarized with various serverless concepts on OpenShift Cloud Functions. Good Luck!

Additional Resources

Don’t stop now! The next scenario will only take about 10 minutes to complete.

Creating and Using Packages on OCF

Step 1 of 5

Step 1

Getting Started

1. Browsing existing packages

Before we start creating our own packages, let's take a look and see what's already there.

wsk -i package list /whisk.system

Executing this command will return a result like this:

/whisk.system/weather                                                  shared
/whisk.system/websocket                                                shared
/whisk.system/github                                                   shared
/whisk.system/watson-translator                                        shared
/whisk.system/watson-textToSpeech                                      shared
/whisk.system/samples                                                  shared
/whisk.system/utils                                                    shared
/whisk.system/slack                                                    shared
/whisk.system/watson-speechToText                                      shared
/whisk.system/combinators                                              shared
/whisk.system/alarmsWeb                                                private
/whisk.system/alarms                                                   shared

These are the default packages installed when Apache OpenWhisk is first installed. Knowing how to list these packages will help us verify our own packages are being properly created. We can dig even deeper and see what is in a given package:

wsk -i package get --summary /whisk.system/alarms

This will give us this output:

package /whisk.system/alarms: Alarms and periodic utility
   (parameters: *apihost, *trigger_payload)
 feed   /whisk.system/alarms/interval: Fire trigger at specified interval
   (parameters: minutes, startDate, stopDate)
 feed   /whisk.system/alarms/once: Fire trigger once when alarm occurs
   (parameters: date, deleteAfterFire)
 feed   /whisk.system/alarms/alarm: Fire trigger when alarm occurs
   (parameters: cron, startDate, stopDate)

Here we can see that the alarms package contains three feeds. Additionally, we can see these feeds all take various parameter values. We will look in to how to make use of this kind of information as we proceed.

2. Creating a package

For this scenario, we will be creating a set of conversion routines: temperatures, distances, etc. So the first step is to create a package to hold all our conversion functions:

wsk -i package create conversions

This command should execute quite quickly and seem like nothing was actually done but we can verify our new package was created:

wsk -i package list | grep conversions

This will give a result like:

/whisk.system/conversions                                              private


With our package created, we can begin to add some functionality.