OpenWhisk Serverless Platform Installation
Apache OpenWhisk is an open-source, event-driven serverless computing platform that executes functions in response to triggers and events. This guide covers deploying OpenWhisk on Linux, creating actions, configuring trigger rules, and integrating with Kubernetes for production-grade serverless workloads.
Prerequisites
- Ubuntu 20.04/22.04 or CentOS 8/Rocky Linux 8+
- Docker and Docker Compose installed
- Minimum 4 GB RAM, 2 CPUs
curlandgitinstalled- For Kubernetes deployment: a running cluster with
kubectlaccess
Install OpenWhisk with Docker Compose
Clone the OpenWhisk devtools repository and start the stack:
# Clone the quick deployment repo
git clone https://github.com/apache/openwhisk-devtools.git
cd openwhisk-devtools/docker-compose
# Set your host IP (replace with your actual server IP)
export OPENWHISK_HOST=$(hostname -I | awk '{print $1}')
# Start OpenWhisk
make quick-start
Wait for all containers to become healthy (2-5 minutes). Verify the stack:
docker ps --format "table {{.Names}}\t{{.Status}}"
You should see containers for owdev-controller, owdev-invoker, owdev-apigateway, owdev-kafka, and owdev-couchdb all in a healthy state.
Configure the wsk CLI
Download and configure the OpenWhisk CLI (wsk):
# Download wsk CLI (Linux amd64)
curl -Lo wsk https://github.com/apache/openwhisk-cli/releases/download/latest/OpenWhisk_CLI-latest-linux-amd64.tgz
# Or download the tarball
wget https://github.com/apache/openwhisk-cli/releases/latest/download/OpenWhisk_CLI-latest-linux-amd64.tgz
tar -xzf OpenWhisk_CLI-latest-linux-amd64.tgz
sudo mv wsk /usr/local/bin/
# Configure the CLI to point at your local OpenWhisk
wsk property set \
--apihost "http://${OPENWHISK_HOST}:3233" \
--auth "23bc46b1-71f6-4ed5-8c54-816aa4f8c502:123zO3xZCLrMN6v2BKK1dXYFpXlPkccOFqm12CdAsMgRU4VrNZ9lyGVCGuMDGIwP"
The default auth key above is the default guest key for development. For production, set up proper namespaces and auth.
Verify the connection:
wsk namespace list
# Should return: namespaces
# guest
Create and Invoke Actions
Actions are the core unit of execution in OpenWhisk. Create a simple Node.js action:
# Create a simple JavaScript action
cat > hello.js << 'EOF'
function main(params) {
const name = params.name || 'World';
return { greeting: `Hello, ${name}!` };
}
EOF
# Create the action
wsk action create hello hello.js
# List actions
wsk action list
# Invoke synchronously
wsk action invoke hello --param name "OpenWhisk" --result
# Output: { "greeting": "Hello, OpenWhisk!" }
# Invoke asynchronously and get the activation ID
wsk action invoke hello --param name "VPS"
# ok: invoked /_/hello with id <activation-id>
# Check activation result
wsk activation get <activation-id>
wsk activation logs <activation-id>
Create a Python action:
cat > process.py << 'EOF'
def main(args):
import datetime
return {
"message": args.get("msg", "no message"),
"timestamp": datetime.datetime.utcnow().isoformat()
}
EOF
wsk action create process process.py --kind python:3
# Test it
wsk action invoke process --param msg "hello from Python" --result
Triggers and Rules
Triggers fire events; rules connect triggers to actions:
# Create a trigger
wsk trigger create myTrigger
# Create a rule connecting the trigger to the action
wsk rule create myRule myTrigger hello
# Fire the trigger
wsk trigger fire myTrigger --param name "Trigger Test"
# Check the activation log to see the action was called
wsk activation list --limit 5
# Create a scheduled (alarm) trigger - fires every minute
wsk trigger create everyMinute \
--feed /whisk.system/alarms/alarm \
--param cron "*/1 * * * *"
# Connect alarm trigger to action
wsk rule create minuteRule everyMinute hello --param name "Scheduler"
Package Management
Packages group related actions and share parameters:
# Create a package
wsk package create myapp
# Create an action inside the package
wsk action create myapp/greet hello.js
# Set default parameters for the package
wsk package update myapp --param environment "production"
# List packages
wsk package list
# Bind an external package (e.g., the built-in utils package)
wsk package bind /whisk.system/utils myUtils
# List actions in a package
wsk package get myapp --summary
# Share a package (make public)
wsk package update myapp --shared yes
Deploy on Kubernetes
For production, deploy OpenWhisk on Kubernetes using Helm:
# Add the OpenWhisk Helm chart
helm repo add openwhisk https://openwhisk.apache.org/charts
helm repo update
# Create a values file
cat > mycluster.yaml << 'EOF'
whisk:
ingress:
type: NodePort
apiHostName: <YOUR_NODE_IP>
apiHostPort: 31001
nginx:
httpsNodePort: 31001
invoker:
containerFactory:
impl: kubernetes
EOF
# Create namespace and deploy
kubectl create namespace openwhisk
helm install owdev openwhisk/openwhisk \
-n openwhisk \
-f mycluster.yaml
# Wait for deployment
kubectl get pods -n openwhisk --watch
# Configure wsk to use the Kubernetes endpoint
wsk property set \
--apihost https://<YOUR_NODE_IP>:31001 \
--auth <admin-auth-key>
API Gateway Integration
Expose actions as REST API endpoints:
# Create an action to expose
cat > api_action.js << 'EOF'
function main(params) {
return {
statusCode: 200,
headers: { 'Content-Type': 'application/json' },
body: { message: 'API response', id: params.__ow_path }
};
}
EOF
wsk action create apiAction api_action.js --web true
# Create an API endpoint
wsk api create /myapi GET apiAction
# List APIs
wsk api list
# Test the API
curl https://<OPENWHISK_HOST>:3233/api/v1/web/guest/default/apiAction.json
Troubleshooting
Actions time out or fail to invoke:
# Check invoker logs
docker logs owdev-invoker-0 --tail 50
# Check controller logs
docker logs owdev-controller-0 --tail 50
# Increase action timeout (default 60s, max 300s)
wsk action update myAction --timeout 120000
CouchDB connection errors:
# Verify CouchDB is running
docker exec owdev-couchdb curl -s http://localhost:5984/_up
# Check CouchDB logs
docker logs owdev-couchdb --tail 30
wsk authentication errors:
# Verify current property settings
wsk property get
# Reset auth to default guest key
wsk property set --auth "23bc46b1-71f6-4ed5-8c54-816aa4f8c502:123zO3xZCLrMN6v2BKK1dXYFpXlPkccOFqm12CdAsMgRU4VrNZ9lyGVCGuMDGIwP"
Container runtime errors (Docker invoker):
# Ensure Docker socket is accessible
ls -la /var/run/docker.sock
# Check available runtime kinds
wsk property get --apibuild
Conclusion
Apache OpenWhisk provides a production-ready serverless platform that runs entirely on your own infrastructure. With support for multiple runtimes, flexible trigger/rule systems, and Kubernetes deployment, it is a strong choice for event-driven architectures on VPS or baremetal servers. Start with Docker Compose for development and migrate to Kubernetes for scalable production deployments.


