Contents


Setting up Apache OpenWhisk on IBM Power on a single-node, on-premises serverless framework

Proof of concept for IBM Power Architecture support in OpenWhisk

Comments

Serverless computing is a new execution model in cloud computing that allows developers to only focus on coding without having to worry about the infrastructure. A serverless framework takes care of load balancing, fault tolerance, and other infrastructure hassles that would otherwise be the software developer's concern.

Apache OpenWhisk is a serverless framework that can enable developers to quickly and easily build feature-rich apps that support triggering a response to events, inherently.

OpenWhisk on Power

OpenWhisk can be used locally to create a serverless infrastructure. This can help in many scenarios. The serverless backend services remove the pain of infrastructural and operational complexities such as fault tolerance, load balancing, and auto-scaling for the developer. This helps the developer to concentrate on writing the code while the execution is taken care by OpenWhisk. Given that the majority of the application code is architecture neutral (such as Python, Java, Scala, and Nodejs) the developer does not need to worry about the architecture backend to run the code.

Resource utilization is optimized tremendously when you use a serverless backend system because the code is run only when it is called. Serverless frameworks are gaining popularity in performing edge computing for Internet of Things (IoT) solutions.

Docker is used as the primary runtime in OpenWhisk that is already enabled and available on IBM® Power® servers. For more information, see Docker on IBM Power Systems.

Hence, enabling OpenWhisk becomes a usual next step to allow you to use serverless computing on IBM Power servers.

Environment requirements

Refer to the following environment details to build OpenWhisk on Power:

  • Obtain an Ubuntu 16.04 ppc64le environment. This can be bare metal or a virtual machine. Install Python on it. If you need to obtain a ppc64le cloud VM for Ubuntu 16.04, visit https://cloud-images.ubuntu.com/xenial/current/
  • Make sure that you have proper internet access to download various Docker packages.

Prerequisites

The OpenWhisk framework is built using a collection of Docker images that are obtained from various sources in Docker Hub. Some of these images are either already available for the IBM POWER® processor-based hardware or they are available in a different version other than the one that OpenWhisk installer expects. There are rarely a couple of images that would have to be hand built following the instructions in this document till they become available by default from the Docker registry. To circumvent some of these image issues, you need to take care of the following steps:

Set up an ephemeral CouchDB instance

The deployment scripts of OpenWhisk are written with CouchDB 1.6. However, the official ppc64le/CouchDB has a 2.0.0 image. CouchDB has changed a few of the API paths in 2.0.0. This results in the image being unusable through the default settings of OpenWhisk. Hence, you need to complete the following process:

  1. Manually perform a Docker run using the following command:
    docker run -p 5984:5984 -d ppc64le/couchdb:2.0.0
  2. Create an admin user and password (sample values used):
    curl -X POST -H "Content-Type: application/json" http:// 127.0.0.1:5984/_cluster_setup -d 
    '{"action": "enable_cluster", "bind_address":"0.0.0.0", "username": "admin", "password":"password"}
  3. To create system databases on startup, run the following commands:
    curl -X PUT http://admin:password@127.0.0.1:5984/_config
    curl -X PUT http://admin:password@127.0.0.1:5984/_membership
    curl -X PUT http://admin:password@127.0.0.1:5984/_global_changes

After running these commands, the initial setup of CouchDB is completed on a single-node cluster. For more information, see: http://docs.couchdb.org/en/2.0.0/install/#single-node-setup

Note: This is an ephemeral CouchDB instance. You can make it non-ephemeral by passing a disk to this CouchDB container that can persist the state.

Building gliderlabs/registrator

The registrator docker image does not exist for the IBM Power Architecture® in the Docker hub. You need to complete the following steps to build the image for Power manually:

  1. Create a Git clone of the https://github.com/gliderlabs/registrator repository.
  2. Modify the Docker file to use the official alpine 3.6 ppc64le image. The original image is built with alpine 3.5.

Building ches/kafka

OpenWhisk requires ches/kafka because it creates the Apache Kafka topics by using the script provided by this image. This image does not exist for ppc64le and hence has to be built manually.

Deploying OpenWhisk on Power

The following section lists down the steps that you need to perform to deploy Apache OpenWhisk on the IBM Power Architecture.

Clone the power-support branch

The IBM Power Architecture support for OpenWhisk has not been merged upstream but can be obtained from the GitHub for the time being.

You should clone this repository and switch over to the power-support branch.

Set up CouchDB credentials

The user ID and password information that has been set to run the steps while setting up CouchDB should be manually populated inside the openwhisk/db_local.ini file.

Refer to the following sample file:

[db_creds]
db_provider=CouchDB
db_username=admin
db_password=password
db_protocol=http
db_host=172.17.0.1 //This is your Ubuntu machine’s IP.
db_port=5984

Install OpenWhisk on Power

Up until now, the steps executed are to create pre-requisites to run the OpenWhisk installer. If you have successfully executed the above steps, you are good to perform the following steps to kick off the installation of Apache OpenWhisk on Power Architecture.

  1. After cloning the OpenWhisk repository under /home/ubuntu, run the following commands:
    1. cd /home/ubuntu/openwhisk; cd tools/ubuntu-setup && ./all.sh
    2. ./gradlew distDocker
  2. Switch over to the ansible directory under openwhisk/ansible and run the following commands:
    ansible-playbook -i environments/local/host setup.yml
    ansible-playbook -i environments/local/host prereq.yml
    ansible-playbook -i environments/<environment> couchdb.yml
    ansible-playbook -i environments/<environment> initdb.yml
    ansible-playbook -i environments/<environment> wipe.yml
    ansible-playbook -i environments/<environment> openwhisk.yml
    ansible-playbook -i environments/<environment> postdeploy.yml

Note: The version of the consul image that is used with OpenWhisk is 0.7.5, while the version that is available on the Power server is 0.8.1. You can manually pull the consul image for 0.8.1 and update the correct consul name or version in the openwhisk/group_vars/all file.

Sample run on OpenWhisk

After successfully running the previous steps, you should have an all-in-one OpenWhisk framework working on Power. The following steps guide you in running a few sample commands that help you understand the working functionality in OpenWhisk:

  1. Run the following command to set the authorization key:
    /home/ubuntu/openwhisk/ansible/../bin/wsk property set  --auth 
    `cat /home/ubuntu/openwhisk/ansible/files/auth.guest`

    After the authorization key is set, you do not have to use it with the wsk command line every time.

  2. Run the following command to set the AIP host IP:

    /home/ubuntu/openwhisk/ansible/../bin/wsk property set --apihost 172.17.0.1

  3. Create an OpenWhisk action by running the following command:

    /home/ubuntu/openwhisk/ansible/../bin/wsk -i action create hello hello.js

    Verify that an output similar to the following message is displayed:

    ok: created action hello

    An action is essentially a piece of code that should be run based on a trigger.

  4. Run the following command to perform a test by invoking the OpenWhisk action:
    /home/ubuntu/openwhisk/ansible/../bin/wsk -i action invoke --blocking hello
    ok: invoked /_/hello with id 1319b4cb784743c8bf405c32caa972b4

Along with this, OpenWhisk provides a catalog of packages that can be used for various use cases.

Note: The fork of the OpenWhisk Git repository must be used for proof of concepts only and not for production. It has to be upstreamed into the main Git repository of OpenWhisk as an additional step which might require further clean up and design discussions with respect to enabling multi-architecture OpenWhisk deployments.

Conclusion

This article described the steps to bring up a fully functional OpenWhisk cluster. It showed that the user experience of using OpenWhisk remains almost unchanged while the underlying platform is switched to IBM Power servers.

Serverless frameworks are gaining popularity and the IBM Power hardware can be the best platform to run some of the serverless customer solutions due to the great platform benefits of the architecture.

Acknowledgment

I would like to thank Pradipta Kumar Banerjee – STSM, Linux Technology Center, IBM systems, for his constant feedback and direction in creating this article.

References


Downloadable resources


Comments

Sign in or register to add and subscribe to comments.

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Linux
ArticleID=1049089
ArticleTitle=Setting up Apache OpenWhisk on IBM Power on a single-node, on-premises serverless framework
publish-date=08302017