OpenWhisk Serverless

Apache OpenWhisk hello world

In this post we see how to deploy Apache OpenWhisk, an open source serverless platform, and how to create an example of hello world action.

This example was done using Docker Desktop on Windows 10 with Ubuntu 18.04 WSL 2.
We will see how to deploy OpenWhisk to other Kubernetes clusters in next posts.

We will use Helm to deploy OpenWhisk on Kubernetes so let’s install it.

curl | sudo apt-key add -
sudo apt-get install apt-transport-https --yes
echo "deb all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list
sudo apt-get update
sudo apt-get install helm

Clone the Git openwhisk-deploy-kube repo.

git clone
cd openwhisk-deploy-kube

Check that InternalIP is and port 31001 is available.

kubectl describe nodes | grep "InternalIP"
sudo netstat -tulpn | grep 31001

Create a mycluster.yaml file.

    type: NodePort
    apiHostPort: 31001

  httpsNodePort: 31001

Create a Kubernetes namespace for OpenWhisk.

kubectl create namespace openwhisk

Indicate that all nodes can be used by OpenWhisk to execute containers.

kubectl label nodes --all openwhisk-role=invoker

Deploy OpenWhisk using Helm.

helm install owdev ./helm/openwhisk -n openwhisk -f mycluster.yaml

Wait for the deployment to be complete by observing the status of the pods created.

kubectl -n openwhisk get pod -w

The deployment will be finished when the install-packages pod status is completed.

OpenWhisk deploy completed

Install the wsk cli.

curl -L -O
mkdir wsk-cli
tar -xvzf OpenWhisk_CLI-1.1.0-linux-amd64.tgz -C wsk-cli
sudo ln -s $HOME/wsk-cli/wsk /usr/local/bin/wsk

Configure the wsk cli apihost property.

wsk -i property set --apihost localhost:31001

List users in the guest namespace.

kubectl -n openwhisk -ti exec owdev-wskadmin -- wskadmin user list guest

And use the string you get to set the wsk cli auth property.

wsk -i property set --auth 23bc46b1-71f6-4ed5-8c54-816aa4f8c502:123zO3xZCLrMN6v2BKK1dXYFpXlPkccOFqm12CdAsMgRU4VrNZ9lyGVCGuMDGIwP

Create a JavaScript file, helloWorldAction.js, for a Node.js serverless function.

const os = require('os')

function main(params) {
    const name = params && || 'anonymous'
    const hostname = os.hostname()
    const message = `Hello ${name} from ${hostname}`
    const body = JSON.stringify({
    const response = {
        statusCode: 200,
        headers: { 'Content-Type': 'application/json' },
    return response

Create a web action.

wsk -i action create helloWorldAction helloWorldAction.js --web true

You can now invoke the action from shell.

wsk -i action invoke helloWorldAction --result --param name Roberto

You will see that OpenWhisk creates automatically containers running your serverless function.

OpenWhisk creating Node.js web actions containers.

Or get the action URL to use it as a webservice.

wsk -i action get helloWorldAction --url

You can use the action URL to test it through Postman.

Testing an OpenWhisk web action with Postman

If you want to remove OpenWhisk you can do it through Helm.

helm -n openwhisk delete owdev

Delete all remaining pods.

kubectl -n openwhisk delete pod --all

Remove the label and the namespace.

kubectl label node docker-desktop openwhisk-role-
kubectl delete namespaces openwhisk

In next posts we will see examples about how to use all components of the Apache OpenWhisk programming model.

OpenWhisk programming model