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

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.

In the previous article, we have set up our Elastic Compute Service (ECS) instance and configured it with Docker. Now, we need to install CouchDB on the system and complete the OpenWhisk installation.

What Is Couch DB?

CouchDB is one of many offerings available in the NoSQL space and is a document-based database. All the data is stored in the JSON documents as a key value pairs as a map. The unique feature of CouchDB is there is also a _rev(revision) along with _id(Unique identifier) shows how many changes are made.

The advantage of CouchDB over other NoSql offerings are

  • CouchDB is constructed in such a way that, it can grow easily into a cluster depends upon your needs
  • CouchDB also has an in-built managed cache, which is responsible for fast responses
  • You can also listen to the _changes(changes) feed to keep tracking of changes which are made.

Installing CouchDB

Adding the CouchDB GPG key to the keyring, by executing following command

You will get the output similar to this

Adding the repository to the sources

Updating the apt system

Install the CouchDB using the command here:

While installing the CouchDB you will get the following screens for some information. The first screen asking for which type of installation is preferred, I chose standalone since we are prototyping

In next screen it will ask for the binding IP, like below. Choose 0.0.0.0

Then the admin password, the username by default is “admin”. You can change this account and password later, but it is important to have those details here

Repeat the password

Once you confirm the password, the installation resumes and all the dependencies will be installed.

You can check the service status of the couch DB using the command below

The command gives an output similar to this showing the running state as active

One of the big features of CouchDB is the availability of REST API. If you run the following command, you should see all the information in a JSON format. This confirms that the API is up and running on the server

Now, we will access fauxton which is installed as part of the CouchDB to make some configuration changes

The fauxton will be running in the same port as the CouchDB, headover to the browser and hit http://:5984 and you will see a login screen

Login with your credentials created while installing the CouchDB, once you are logged in CouchDB will setup a default system database with all the relevant details, where we can manage users, replicators, global variables etc..

You can also change the credentials, create new users and the IP Address binding for each specific user right from the web console

Here I am creating the user “admin1” default to the same port and the IP address and click on “Configure Node”. That will take of creating the database in the background. Apache Openwhisk strongly recommends to change the “reduce_limit” property value of the CouchDB to false.

You will find it under the console > settings > “query_server_config” > reduce_limit change it to “false” by clicking on that. Once you click save you will see the prompt after the successful update like below

Once you have done this, you can also do the same using the standard REST API. To see what are all the users available. You can run the following command

The error is common you need to authenticate the user when invoking the REST API. This can be fixed by adding a user authentication while making the call.

If you wish to see the “_global_changes” DB realted information you will do so by

Install OpenWhisk

Now we have completed the setup of CouchDB, we will install the Apache OpenWhisk.

We need to clone the git repository. The below command will clone the code into the openwhisk folder.

Change to openwhisk directory and run the scripts.

Run the scripts, with sudo, as these scripts invoke sudo as part of their process

You can see as above the script is running and it will take a while, keep track on the console, whether the installation is successful or any warnings popped up. If your installation is successful, you will see the below output at the end.

Now, it’s time to run some ansible scripts, the scripts are generated under the ansible folder under openwhisk, change to ansible directory

Export all the DB parameters, the DB IP should be accessible from outside the Virtual Machine

Apache Openwhisk team does a great job in providing the scripts for the complex installation, when we run the setup.yml it will generate all the config files

Install the prerequsites on all the openwhisk nodes

Build and distribute the docker images using docker, make sure you move to the openwhisk root repository

Deploying CouchDB and openwhisk deployment

Now you can find the docker process by running the following command,

You will see all the nodes are running with different workloads on them

You can see all the relevant dependencies nginx, nodejs6, kafka, redis, zookeeper working on different docker containers

Change to binaries of the openwhisk directory, and add the tool to the path

You will be able to see the openwhisk after the successful installation like above message

Create file hello.js and update with the file

Then, copy the below code

Create an action named ‘hello’ using the command line tool

You can invoke the action using this, add -i for disabling authentication

Congratulations! It means Apache OpenWhisk is installed on your Ubuntu machine and operational. You can learn about working on Apache OpenWhisk here: https://github.com/apache/incubator-openwhisk?spm=a2c41.12784455.0.0

Reference:

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

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