Getting Started
As a developer, you need the right tools for the job.
This section describes the various tools that you can use
to work with OpenWhisk which include:
OpenWhisk CLI (wsk)
OpenWhisk offers the wsk
Command Line Interface
(CLI) to easily create, run, and manage OpenWhisk entities.
For detailed information on setting up and configuring the
OpenWhisk CLI, go to the
OpenWhisk CLI
documentation page in GitHub.
Installing
You have a couple of choices on how to install the Whisk CLI
depending on your target Operating System:
Using Homebrew (Linux or Mac)
To easily install the OpenWhisk CLI (wsk) you can
use Homebrew for Mac
or Homebrew for Linux.
{% highlight bash %}
$ brew update
$ brew install wsk
{% endhighlight %}
Then you can invoke the OpenWhisk CLI by just
typing wsk
from the command line.
Download and install the wsk CLI from (Linux, Mac or Windows):
-
Download the OpenWhisk CLI for your Operating System as
a standalone compressed TAR Archive file (.tgz
)
or ZIP file (.zip
) from the project
Releases page
in GitHub:
where you may select to download the CLI from one of the versioned releases.
Uncompress the wsk
executable from
the tar.gz
file.
-
Simplify access to the wsk
executable by
moving or copying the binary file to a path listed
in your PATH
environment variable.
This will enable you to invoke the OpenWhisk CLI by
just typing 'wsk
' on the command line
from anywhere.
For example:
Linux: Move the wsk
executable
to your local bin
directory:
{% highlight bash %}$ sudo mv [full path to downloaded wsk executable] /usr/local/bin/wsk{% endhighlight %}
-
Windows: Follow instructions as linked here:
Verify Installation
You can verify your installation by invoking the Whisk
CLI's help command:
{% highlight bash %}$ wsk --help{% endhighlight %}
Configuring
Before using the OpenWhisk CLI, you must first configure it
to point to the OpenWhisk platform you want the utility
to use (i.e., its API endpoint) and also provide it with your
associated authentication credentials.
Setting the API Host and
Authentication Key
You can configure wsk CLI to use your OpenWhisk
credentials in few different ways. See the
Setting up the OpenWhisk CLI
page for a full set of configuration options.
The instructions below walk you through the simplest
possible configuration using only an
API_HOST
and AUTH_KEY
CLI
properties using a default guest
namespace.
wsk property setup
Run the following command to set whisk API HOST and
authorization key to create the configuration file:
{% highlight bash %}
$ wsk property set --apihost API_HOST --auth AUTH_KEY --namespace guest
{% endhighlight %}
The OpenWhisk CLI stores the properties set
in ~/.wskprops
by default.
The location of this file can be altered by setting the
WSK_CONFIG_FILE
environment variable.
For example:
{% highlight bash %}
$ export WSK_CONFIG_FILE=your-config-file
{% endhighlight %}
Verify properties
Verify your properties were properly set by
using the wsk property get
command:
{% highlight bash %}
$ wsk property get
{% endhighlight %}
Test configuration
A simple "read" command will cause the CLI to authenticate
to the OpenWhisk your configured API host endpoint and
credentials.
is incorrect.
Verify host connection
Verify your host connection and credentials using
the wsk list
command with the
-v
(verbose) flag enabled.
{% highlight bash %}
$ wsk list -v
{% endhighlight %}
You should see the full HTTP request and response headers
the CLI sends/receives to/from the host along with the
response codes.
Whisk Deploy (wskdeploy)
Whisk Deploy
is a utility, named wskdeploy, to help deploy and
manage all your OpenWhisk Packages, Actions, Triggers, Rules
and APIs from a single command using an application manifest.
Whisk deploy in the wsk CLI
The functionality of wskdeploy is also embedded as the deploy
subcommand within the wsk CLI. The functionality is identical and supports all the same parameters and flags. This means that you can use the wsk deploy
subcommand if you already have the CLI installed or follow the instructions below on installing the wskdeploy utility for standalone use.
Installing
Download and Install the wskdeploy
utility
for Linux, Mac or Windows.
Download the Whisk Deploy utility
-
Download the Whisk Deploy utility for your Operating
System as a standalone compressed TAR Archive
file (.tgz
) or ZIP file (.zip
)
from the project
Releases page
in GitHub:
where you may select to download the utility from one of the versioned releases.
-
Uncompress the wskdeploy
executable from
the tar.gz
file.
-
Simplify access to the wsk
executable by
moving or copying the binary file to a path listed
in your PATH
environment variable.
This will enable you to invoke Whisk Deploy utility by
just typing 'wskdeploy
' on the command line
from anywhere.
Follow the
instructions
as shown for the Whisk CLI to learn how to do this for
your development platform.
Verify Installation
Start by verifying the utility can display the command
line help:
{% highlight bash %}$ wskdeploy --help{% endhighlight %}
Configure
Before you proceed with the deployment, please make sure you have
setup the API_HOST
and AUTH_KEY
CLI
properties with a default namespace as described in the
Whisk CLI configuration
section above.
Test configuration
-
Create and Deploy a simple OpenWhisk Manifest File
Please refer to the
Whisk Deploy Programming Guide
for all manifest file grammar and syntax. This programming
guide has step-by-step instructions for deploying OpenWhisk
applications using wskdeploy.
Here is a simple YAML manifest example that has an in-line
function written in JavaScript that outputs "Hello World":
{% highlight yaml %}
{% include code/manifest-for-helloJS-2.yaml %}
{% endhighlight %}
- Save the YAML scripts as an OpenWhisk Manifest file
called
manifest.yaml
-
Deploy the OpenWhisk Manifest file:
{% highlight bash %}$ wskdeploy -m manifest.yaml{% endhighlight %}
Additional Resources
Medium Blogs (tagged wskdeploy)
OpenWhisk REST API
After your OpenWhisk environment is enabled, you can use
OpenWhisk with your web apps or mobile apps with REST API
calls.
For more details about the APIs for actions, activations,
packages, rules, and triggers, see the
OpenWhisk API
documentation.
OpenWhisk Clients
OpenWhisk provides a wrapper around the OpenWhisk APIs in
multiple different languages. These can be imported and used
directly in your favorite Integrated Development
Environment (IDE):