Unlock the Power of Serverless Architecture with Apache OpenWhisk

Imagine building and deploying applications without the hassle of managing servers. Apache OpenWhisk, a mature and feature-rich serverless framework, makes this a reality. With its open-source platform, developers can enjoy high scalability, fast time-to-release, and lower costs.

What is Apache OpenWhisk?

Apache OpenWhisk, developed by the Apache Software Foundation, supports a wide range of programming languages, including Node.js, Swift, Java, Go, and Scala. Compared to other mainstream serverless platforms like AWS Lambda or Azure Functions, OpenWhisk offers similar capabilities, such as a rich programming model, broad language support, scalability, and efficiency. However, its open-source nature provides the freedom to deploy on-premises or to a cloud provider, avoiding vendor lock-in.

Setting Up OpenWhisk Locally

To set up a local OpenWhisk development environment, you’ll need Docker with Kubernetes enabled and Helm as the package manager for the local Kubernetes cluster. Follow these steps to clone the Apache OpenWhisk Kubernetes Deployment repository, deploy Charts, and install the OpenWhisk CLI.

Building a Serverless Node.js App

Using the Serverless framework, an open-source npm package, we can deploy serverless functions into various platforms. Create a Node.js app skeleton using the predefined template from Serverless, and explore the project structure, including the serverless.yml file and handler.js file.

Creating Actions and Triggers

Learn how to create a userCreate action to add a new user, update the serverless.yml file to add the configuration of the new function, and deploy the service. Then, explore how to call an external API from an OpenWhisk action, sending a Slack message to a Slack app channel.

Configuring Triggers and Rules

Understand how OpenWhisk triggers and rules work together to associate triggers with actions. Create a trigger and rule to post a Slack message after a new user is created, and modify the createUser function to invoke the newuserTrigger programmatically.

Creating Action Sequences

Discover how to perform multiple tasks one by one using OpenWhisk’s sequences feature. Create a sequence based on the userCreate and listUser actions, and link them together to make a sequence. Deploy the service again and test the newly-created action and sequence.

Summary

In this article, we’ve covered how to set up a local OpenWhisk environment, create a serverless Node.js app, and demonstrate the features of OpenWhisk, including creating web actions, triggers, rules, and sequences. With OpenWhisk and the Serverless framework, you can build and deploy scalable, efficient, and cost-effective applications.

Leave a Reply

Your email address will not be published. Required fields are marked *