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.
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 openwhiskAfter cloning, the repository structure is shown in the accompanying image.
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.shConfigure 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=5984Deploy 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.ymlVerify Docker Containers
After a successful deployment, OpenWhisk runs several Docker containers. List them with:
docker ps --format "{{.Image}} {{.Names }}"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`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 20Conclusion
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.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
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.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
