Installing OpenWhisk

At the time of writing, the quickest way to install OpenWhisk on a local machine is to use Docker and Docker Compose.

To install Docker Compose, we can follow instructions from https://github.com/docker/compose/releases:

$ sudo curl -L https://github.com/docker/compose/releases/download/1.17.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose

To check the version of Docker Compose, use the following command:

$ docker-compose --version
docker-compose version 1.17.1, build 6d101fb

We use Docker Compose 1.17.1 in this chapter.

Also check if the Git is installed already. If so, now we are ready to install a local OpenWhisk instance.

First, clone the OpenWhisk Dev tools repository from GitHub (https://github.com/apache/incubator-openwhisk-devtools) using the following command:

$ git clone --depth=1 https://github.com/apache/incubator-openwhisk-devtools

The --depth=1 tells git to shallow clone the repository, which means that only the latest revision of the Git history will be there to save time and space.

Next, move into the directory incubator-openwhisk-devtools/docker-compose. This directory contains docker-compose.yml and the required environment variables to start a single node OpenWhisk instance. Look for a Makefile there; it contains the quick-start target to provision an instance, set up the initial data, and invoke an example function:

$ make quick-start

The command will be doing the following.

First, it will download the latest source of OpenWhisk from the master branch of its GitHub repository, along with the wsk CLI binary. Second, it will start an OpenWhisk local cluster and initialize the data with the Ansible playbooks that came with the OpenWhisk source tree. Then it will register the hello-world function and finally invoke it:

Response body size is 9 bytes
Response body received:
["guest"]
ok: whisk auth set. Run 'wsk property get --auth' to see the new value.
ok: whisk API host set to 192.168.1.40:443
ok: whisk namespace set to guest
waiting for the Whisk invoker to come up ...
creating the hello.js function ...
invoking the hello-world function ...
adding the function to whisk ...
ok: created action hello
invoking the function ...
invocation result: { "payload": "Hello, World!" }
{ "payload": "Hello, World!" }
deleting the function ...
ok: deleted action hello
To invoke the function again use: make hello-world
To stop openwhisk use: make destroy

Sometimes, when the process is up and running, the instance becomes flaky. Simply press Ctrl + C and issue the command make run instead of make quick-start to try to start the instance again. If you'd like to start over, simply run the make destroy command to destroy the instance. After destroying it, you can start over with make quick-start.

If the output ends like this, OpenWhisk is now ready to serve at localhost:443:

Response body received:
["guest"]
ok: whisk auth set. Run 'wsk property get --auth' to see the new value.
ok: whisk API host set to localhost:443
ok: whisk namespace set to guest

We can then use the docker ps command to double check that all OpenWhisk containers are running:

$ docker ps --format "table {{.ID}}	{{.Image}}"
CONTAINER ID IMAGE
5e44dca4c542 openwhisk/nodejs6action:latest
d784018ef3de adobeapiplatform/apigateway:1.1.0
74b6b1d71510 openwhisk/controller
0c0cb4779412 openwhisk/invoker
b0111898e1a8 nginx:latest
874dac58a7c1 landoop/kafka-topics-ui:0.9.3
611e9b97ad74 confluentinc/cp-kafka-rest:3.3.1
4e1a82df737e wurstmeister/kafka:0.11.0.1
9c490336abff redis:2.8
abc4c0845fac couchdb:1.6
451ab4c7bf45 zookeeper:3.4
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset