Hero Image

OpenWhisk server

Configuring the OpenWhisk server

Manually setting up Openwhisk and CouchDB on a fresh Ubuntu 16.04 server.

Based on the OpenWhisk Ansible README, which at the time of writing is missing some key steps - hence this new guide.

  1. Dependencies
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install git python-pip python-setuptools build-essential libssl-dev libffi-dev python-dev software-properties-common
sudo pip install ansible==2.1.2.0

Install Docker:

sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
sudo apt-add-repository 'deb https://apt.dockerproject.org/repo ubuntu-xenial main'
sudo apt-get install docker-engine -y

You can check whether Docker is running via sudo service docker status. Also, importantly, make sure to [enable the remote API]

sudo vi /lib/systemd/system/docker.service

Modify the line that starts with ExecStart to look like this:

ExecStart=/usr/bin/docker daemon -H fd:// -H tcp://0.0.0.0:4243

Restart docker!

sudo service docker restart
  1. CouchDB

We're using a self-hosted CouchDB here, but you can choose to skip this step and use an ephemeral CouchDB or Cloudant instead.

sudo add-apt-repository ppa:couchdb/stable -y
sudo apt-get update
sudo apt-get install couchdb -y

Secure the database and add an admin user:

sudo service couchdb stop
sudo chown -R couchdb:couchdb /usr/share/couchdb /etc/couchdb /usr/bin/couchdb
sudo chmod -R 0770 /usr/share/couchdb /etc/couchdb /usr/bin/couchdb
sudo service couchdb start
curl -X PUT localhost:5984/_config/admins/USERNAME -d '"PASSWORD"'

Set the reduce_limit property to false (as per OpenWhisk instructions):

curl -X PUT localhost:5984/_config/query_server_config/reduce_limit -d '"false"' -u USERNAME:PASSWORD

Also set bind_address=0.0.0.0 in /etc/couchdb/local.ini and restart via sudo service couchdb restart to access CouchDB from Docker containers: running curl <your CouchDB IP>:5984 should now output CouchDB info.

  1. OpenWhisk

Important! Run the following Ansible commands with the root user (e.g. via sudo su -), since using another username seems to mess up the database table names!

git clone https://github.com/openwhisk/openwhisk.git
cd openwhisk
(cd tools/ubuntu-setup && ./all.sh)

Configure our database parameters:

cd ansible
export OW_DB=CouchDB
export OW_DB_PROTOCOL=http
export OW_DB_HOST=<the IP of your CouchDB server (should be accessible from Docker containers)>
export OW_DB_PORT=5984
export OW_DB_USERNAME=USERNAME
export OW_DB_PASSWORD=PASSWORD

ansible-playbook setup.yml

Now db_local.ini should contain the correct DB settings. Let's continue with building OpenWhisk (it'll take a while):

ansible-playbook prereq.yml
cd ~/openwhisk
./gradlew distDocker

And deploying it:

cd ansible
ansible-playbook initdb.yml
ansible-playbook wipe.yml
ansible-playbook apigateway.yml
ansible-playbook openwhisk.yml
ansible-playbook postdeploy.yml