Cloud Native 8 min read

How to Install and Test Apache OpenWhisk on Ubuntu: A Step‑by‑Step Guide

This guide walks you through installing Apache OpenWhisk on an Ubuntu 18.04 desktop, configuring its limits and CouchDB storage, deploying the platform with Ansible, setting up the wsk CLI, and creating and invoking a simple Fibonacci action to verify the deployment.

Alibaba Cloud Native
Alibaba Cloud Native
Alibaba Cloud Native
How to Install and Test Apache OpenWhisk on Ubuntu: A Step‑by‑Step Guide

Introduction

Apache OpenWhisk is an open‑source, serverless FaaS platform that runs actions in containers in response to events. The article provides a practical, end‑to‑end tutorial for installing OpenWhisk on Ubuntu 18.04 Desktop.

Prerequisites

Ubuntu 18.04 Desktop

Git installed ( apt install git)

Clone the Repository

git clone https://github.com/apache/incubator-openwhisk.git openwhisk

After cloning, the repository structure is shown in the accompanying image.

Apache OpenWhisk project clone
Apache OpenWhisk project clone

Initial Setup

Navigate to the tools directory and run the Ubuntu setup script, which installs Java and other required packages.

cd openwhisk && cd tools/ubuntu-setup && ./all.sh
OpenWhisk installation configuration
OpenWhisk installation configuration

Configure Limits

Edit ansible/environments/group_vars/all to adjust limits such as invocationsPerMinute, concurrentInvocations, and sequenceMaxLength. Example snippet:

limits:
  invocationsPerMinute: "{{ limit_invocations_per_minute | default(60) }}"
  concurrentInvocations: "{{ limit_invocations_concurrent | default(30) }}"
  concurrentInvocationsSystem: "{{ limit_invocations_concurrent_system | default(5000) }}"
  firesPerMinute: "{{ limit_fires_per_minute | default(60) }}"
  sequenceMaxLength: "{{ limit_sequence_max_length | default(50) }}"

Configure Persistent Storage

Set environment variables for CouchDB (or Cloudant). Example:

export OW_DB=CouchDB
export OW_DB_USERNAME=root
export OW_DB_PASSWORD=PASSWORD
export OW_DB_PROTOCOL=http
export OW_DB_HOST=172.17.0.1
export OW_DB_PORT=5984

Deploy with Ansible

Run the series of Ansible playbooks from the openwhisk/ansible directory:

ansible-playbook -i environments/local/ setup.yml
ansible-playbook -i environments/local/ couchdb.yml
ansible-playbook -i environments/local/ initdb.yml
ansible-playbook -i environments/local/ wipe.yml
ansible-playbook -i environments/local/ apigateway.yml
ansible-playbook -i environments/local/ openwhisk.yml
ansible-playbook -i environments/local/ postdeploy.yml
Ansible playbook execution
Ansible playbook execution

Verify Docker Containers

After a successful deployment, OpenWhisk runs several Docker containers. List them with:

docker ps --format "{{.Image}} 	 {{.Names }}"
Docker container list
Docker container list

Configure the wsk CLI

The CLI binary is located in openwhisk/bin. Set the API host and authentication key:

./bin/wsk property set --apihost '172.17.0.1'
./bin/wsk property set --auth `cat ansible/files/auth.guest`
Set API host
Set API host

Test an Action

Create a simple Python action that computes Fibonacci numbers:

# test.py
def main(args):
    num = args.get("number", "30")
    return {"fibonacci": F(int(num))}

def F(n):
    if n == 0:
        return 0
    elif n == 1:
        return 1
    else:
        return F(n - 1) + F(n - 2)

Create the action and invoke it:

/bin/wsk action create myfunction ./test.py --insecure
./bin/wsk -i action invoke myfunction --result --blocking --param number 20
Create function
Create function
Invoke function result
Invoke function result

Conclusion

The article demonstrates a complete workflow: from preparing the Ubuntu environment, cloning and configuring OpenWhisk, deploying with Ansible, setting up the CLI, to creating and invoking a sample action, confirming that the serverless platform is operational.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

CLICloud NativeDockerServerlessAnsibleUbuntuOpenWhisk
Alibaba Cloud Native
Written by

Alibaba Cloud Native

We publish cloud-native tech news, curate in-depth content, host regular events and live streams, and share Alibaba product and user case studies. Join us to explore and share the cloud-native insights you need.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.