Giter VIP home page Giter VIP logo

envoy-serverless's Introduction

envoy-serverless

A version of Cloudant Envoy that deploys to a IBM OpenWhisk - a serverless computing platform. Having Envoy run in a serverless environment has several advantages:

  • you only pay for what you use
  • the OpenWhisk API system handles authentication, including social media oAuth
  • OpenWhisk handles the traffic scaling

Prerequisites

Clone this repository

git clone https://github.com/glynnbird/envoy-serverless.git
cd envoy-serverless

Sign up for a Bluemix account and follow the Getting Started with OpenWhisk guide to download the wsk tool and configure it for your Bluemix account.

In your Bluemix dashboard, create a Cloudant service and make a note of its URL. In the Cloudant dashboard, create a new empty database (say, 'envoydb').

Installation

Create two environment variables containing your Cloudant URL and the database name:

export COUCH_HOST="https://USERNAME:[email protected]"
export ENVOY_DATABASE_NAME="envoydb"

and run the deployment script:

./deploy.sh

The URL of your service will look something like this:

https://service.us.apiconnect.ibmcloud.com/gws/apigateway/api/YOURSERVICEID/envoy/envoydb

You can now visit the "API Management" section of your OpenWhisk dashboard:

  • in the "Definition" tab, tick the box titled: "Require consuming applications to authenticate via API key"
  • in the "Sharing" tab, create an API key

Running

You can test your service with curl:

> curl -H 'x-ibm-client-id: 0bd929c9-c8b7-43f7-856f-f2cbe33b9f50' \ 'https://service.us.apiconnect.ibmcloud.com/gws/apigateway/api/YOURSERVICEID/envoy/envoydb'
{ ... some json .... }

or from PouchDB:

var PouchDB = require('pouchdb');
var url = 'https://service.us.apiconnect.ibmcloud.com/gws/apigateway/api/YOURSERVICEID/envoy/envoydb';
var opts = {
  ajax: { 
    headers: { 
      'x-ibm-client-id': '60eaa0b0-0b84-4b02-abb1-726605890233'
    }
  }
};
var remotedb = new PouchDB(url, opts);

var envoydb = new PouchDB('envoydb')
envoydb.replicate.from(remotedb).on('change', function (info) {
  // handle change
  console.log('change', info)
}).on('paused', function (err) {
  console.log('paused', err)
}).on('active', function () {
  console.log('active')
}).on('denied', function (err) {
  console.log('denied', err)
}).on('complete', function (info) {
 console.log('complete', info)
}).on('error', function (err) {
  console.log('error', err);
});

envoy-serverless's People

Contributors

glynnbird avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

marley77

envoy-serverless's Issues

"wsk: command not found" when installing envoy-serverless to Cloudant, via IBM Cloud Shell

Hi Glynn,

Envoy-serverless looks like an awesome solution to handle user-data!

  • My aim is to link Cloudant with PouchDB (in browser, on a website) - to load unique data for each user.

Environment:

  • Cloudant - lite (free), partitioned, legacy and IAM auth enabled.
  • An IBM-Cloud service credential (which links successfully with PouchDB).
  • IBM-Cloud-Shell for commands (browser CLI, bx version 2.1.1)

The Error:

I followed the steps in your very nice guide, but when I run ./deploy.sh it says:

wsk: command not found for lines 9 and 17-26. <<<<<<<

  • In the deploy.sh source code, each of those lines refer to ENVOY_DATABASE_NAME.
  • As instructed, I have an empty database called ‘envoydb’ (unpartitioned, but I also tried partitioned).

The Error Code:

m@cloudshell:~$ cd envoy-serverless

m@cloudshell:~/envoy-serverless$ export COUCH_HOST="https://apikey-v2-uiflxxxxxxx:4277xxxxxxxxx@29xxxxxxxxx-bluemix.cloudantnosqldb.appdomain.cloud/"

m@cloudshell:~/envoy-serverless$ ./deploy.sh

./deploy.sh: line 9: wsk: command not found
deploy_action all_docs.js
  adding: index.js (deflated 55%)
  adding: lib/access.js (deflated 63%)
  adding: lib/app.js (deflated 15%)
  adding: lib/db.js (deflated 40%)
  adding: lib/security.js (deflated 43%)
  adding: lib/utils.js (deflated 48%)
  adding: lib/uuid.js (deflated 39%)
./deploy_action.sh: line 18: wsk: command not found
deploy_action bulk_docs.js
  adding: index.js (deflated 55%)
  adding: lib/access.js (deflated 63%)
  adding: lib/app.js (deflated 15%)
  adding: lib/db.js (deflated 40%)
  adding: lib/security.js (deflated 43%)
  adding: lib/utils.js (deflated 48%)
  adding: lib/uuid.js (deflated 39%)
./deploy_action.sh: line 18: wsk: command not found
deploy_action changes.js
  adding: index.js (deflated 51%)
  adding: lib/access.js (deflated 63%)
  adding: lib/app.js (deflated 15%)
  adding: lib/db.js (deflated 40%)
  adding: lib/security.js (deflated 43%)
  adding: lib/utils.js (deflated 48%)
  adding: lib/uuid.js (deflated 39%)
./deploy_action.sh: line 18: wsk: command not found
deploy_action del_db.js
  adding: index.js (deflated 48%)
  adding: lib/access.js (deflated 63%)
  adding: lib/app.js (deflated 15%)
  adding: lib/db.js (deflated 40%)
  adding: lib/security.js (deflated 43%)
  adding: lib/utils.js (deflated 48%)
  adding: lib/uuid.js (deflated 39%)
./deploy_action.sh: line 18: wsk: command not found
deploy_action get_bulk_get.js
  adding: index.js (deflated 30%)
  adding: lib/access.js (deflated 63%)
  adding: lib/app.js (deflated 15%)
  adding: lib/db.js (deflated 40%)
  adding: lib/security.js (deflated 43%)
  adding: lib/utils.js (deflated 48%)
  adding: lib/uuid.js (deflated 39%)
./deploy_action.sh: line 18: wsk: command not found
deploy_action get_db.js
  adding: index.js (deflated 58%)
  adding: lib/access.js (deflated 63%)
  adding: lib/app.js (deflated 15%)
  adding: lib/db.js (deflated 40%)
  adding: lib/security.js (deflated 43%)
  adding: lib/utils.js (deflated 48%)
  adding: lib/uuid.js (deflated 39%)
./deploy_action.sh: line 18: wsk: command not found
deploy_action post_bulk_get.js
  adding: index.js (deflated 57%)
  adding: lib/access.js (deflated 63%)
  adding: lib/app.js (deflated 15%)
  adding: lib/db.js (deflated 40%)
  adding: lib/security.js (deflated 43%)
  adding: lib/utils.js (deflated 48%)
  adding: lib/uuid.js (deflated 39%)
./deploy_action.sh: line 18: wsk: command not found
deploy_action put_db.js
  adding: index.js (deflated 57%)
  adding: lib/access.js (deflated 63%)
  adding: lib/app.js (deflated 15%)
  adding: lib/db.js (deflated 40%)
  adding: lib/security.js (deflated 43%)
  adding: lib/utils.js (deflated 48%)
  adding: lib/uuid.js (deflated 39%)
./deploy_action.sh: line 18: wsk: command not found
deploy_action revs_diff.js
  adding: index.js (deflated 48%)
  adding: lib/access.js (deflated 63%)
  adding: lib/app.js (deflated 15%)
  adding: lib/db.js (deflated 40%)
  adding: lib/security.js (deflated 43%)
  adding: lib/utils.js (deflated 48%)
  adding: lib/uuid.js (deflated 39%)
./deploy_action.sh: line 18: wsk: command not found
./deploy.sh: line 17: wsk: command not found
./deploy.sh: line 18: wsk: command not found
./deploy.sh: line 19: wsk: command not found
./deploy.sh: line 20: wsk: command not found
./deploy.sh: line 21: wsk: command not found
./deploy.sh: line 22: wsk: command not found
./deploy.sh: line 23: wsk: command not found
./deploy.sh: line 24: wsk: command not found
./deploy.sh: line 25: wsk: command not found
./deploy.sh: line 26: wsk: command not found

Possible causes:

  1. Maybe envoy-serverless cannot be installed from IBM Cloud Shell?

  2. Perhaps my account config is insufficient:

Targeted account m's Account (c26xxxxxxxxx)

API endpoint: https://cloud.ibm.com
Region: us-east
User: [email protected]
Account: m's Account (c26xxxxxxxxx)
Resource group: No resource group targeted, use 'bx target -g RESOURCE_GROUP'
CF API endpoint:
Org:
Space:

  1. Maybe a database-specific API-key is required for ‘envoydb’, instead of using the IBM-Cloud-level API-key?

  2. Maybe ‘envoydb’ must be the only DB in the Cloudant instance? (currently, I have 2 other db’s, but I’ll delete them if necessary).


Respectfully:

I realize you have many projects, so it’s alright if you can’t get to this.

I'm very excited about this software you’ve created. It could be the perfect bridge between Cloudant and PouchDB (for loading data for each user).

Thank you for reading. I have benefitted from several of your answers on StackOF.

-Marley

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.