How to Set Up Apache OpenWhisk on Ubuntu 18.04 — Part I

By Sai Sarath Chandra, Alibaba Cloud Tech Share Author. Tech Share is Alibaba Cloud’s incentive program to encourage the sharing of technical knowledge and best practices within the cloud community.

Many organizations today are looking at adopting serverless computing to improve efficiency and reduce costs. The significant feature of serverless computing is that it supports event-based programming, which is the heart of the entire Internet of Things (IoT) industry. Serverless computing is capable of handling burstable workloads while supporting virtually infinite scalability.

Serverless is not for everyone because of the potential latency increase in the request-response times. However, even though serverless may not be for everyone, it has played a prominent role in the newer architectures. The reason behind that is because event-based programming helps us save a considerable amount of cost when you compare with the workloads on virtual servers. Plus, there are a lot of applications out there that are not latency sensitive.

There are several open source technologies built by the support of different organizations concentrated on different use-cases. Every open source serverless framework have their uniqueness, which we cannot compare. This tutorial aims at detailing the installation process of Apache OpenWhisk onto your Alibaba Cloud Elastic Compute Service (ECS) Ubuntu 18.04(64-bit) machine.

What Is Apache OpenWhisk?

Apache OpenWhisk (Incubating) is an open source, distributed serverless platform that executes functions (fx) in response to events at any scale. OpenWhisk manages the infrastructure, servers and scaling using Docker containers so you can focus on building amazing and efficient applications.

The OpenWhisk platform supports a programming model in which developers write functional logic (called Actions), in any supported programming language, that can be dynamically scheduled and run in response to associated events (via Triggers) from external sources (Feeds) or HTTP requests. The project includes a REST API-based Command Line Interface (CLI) along with another tooling to support packaging, catalogue services and many popular container deployment options.

If you didn’t understand any of the terms, don’t worry. Let’s look at the definitions of several important terms.

Feeds: A feed is a stream of events which all belong to some trigger T. A feed is controlled by a feed action which handles creating, deleting, pausing, and resuming the stream of events which comprise a feed. The feed action typically interacts with external services which produce the events, via a REST API that manages notifications.

Triggers: A trigger is technically a name for a class of events. Each event belongs to precisely one trigger; by analogy, a trigger resembles a topic in topic-based pub-sub systems. A rule T -> A means “whenever an event from trigger T arrives, invoke action A with the trigger payload.

Actions: Actions are stateless functions that run on the OpenWhisk platform. For example, an action can be used to detect the faces in an image, respond to a database change, react to an API call, or post a Tweet. In general, an action is invoked in response to an event and produces some observable output.

Setting Up Your ECS Instance

You will need an Alibaba Cloud ECS instance with Ubuntu 18.04(64-bit) system image installed. If you are new to Alibaba Cloud, You can create an account by clicking here through which you can use Alibaba Cloud products values over $300 — $1200

There are already many articles that describe the steps for spinning up an ECS instance in detail, so I will briefly go over the steps below.

Steps involved in creating instances:

  • Basic Configurations:
  • Billing method: Make sure you choose “Pay-As-You-Go” if you are prototyping the application
  • Image: You need to select Ubuntu 18.04(64-bit)
Image for post
Image for post
  • Networking
  • All the obvious options here, make sure you select the proper security group here, anyways we can open the ports while we are working on this
  • System Configurations
  • I choose password-based authentication, choose according to your requirement
  • Grouping
  • Preview
  • The complete information of the selected configuration which you can also save it as a template for future single click ECS instance provision.
  • If you wish to release the instance at the later point of time select the Auto-Release schedule

Once your instance is up and running like below,

Image for post
Image for post

Let’s connect to the instance using ssh like below

You will see the latest installed Ubuntu along with the welcome message, we will update the package entries by running the following command

Once done, we will upgrade any obsolete packages. We will know what packages are to be updated and removed by executing below

You will see similar message as below, where it asks for your consent to upgrade

Input ‘Y’ and also if you wish to remove the unused packages, unlike upgrade where it happens after giving consent, removal have to be done by executing below

Which will also give the similar prompt asking for the same. The upgrade will take a while, there might be some warning you might see while installing like below

Fix:

Check for locale, of the target system, by running ‘locale’, you will see the below output

You need to set the “LC_ALL” and “Language” by running

Before we proceed any other we need to point the pip registry to the global site, this can be done by executing the following command

Replace the output with the below text

Now install all the required tools and other packages using the following command

Once the packages are installed, we are ready to install the ansible

If the installation is successful you will get the following message

Installing Docker

Now we will install Docker on our ECS instance. First, add we will add the key and the repository.

Update the repository.

We will set and make sure that stable version from the Docker repository, we can also verify that using the Docker command.

The output should/will be

We will install the docker by running the install command

You can verify the installation by running the following command

The output will show running

We need to make some changes to the configuration file, edit the config file using the command below

And update the “ExecStart” with the line below

We will reload the docker daemon and restart the docker service

Once we see the status as running, we can check the other environment details by running the following command

In next part of this tutorial , we will see the detailed installation instructions for CouchDB, different ways of configuring it either in clustered mode or on a single machine format. Once we complete that, we will proceed with OpenWhisk installation and testing.

Reference:https://www.alibabacloud.com/blog/how-to-set-up-apache-openwhisk-on-ubuntu-18-04-part-i_594683?spm=a2c41.12784391.0.0

Written by

Follow me to keep abreast with the latest technology news, industry insights, and developer trends.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store