A brief introduction to serverless.
One of the latest buzzwords to hit the web development industry recently has been serverless. The name is actually slightly misleading - because the architecture still uses servers - just not yours.
In short, serverless allows you to invoke functions to run on scaleable infrastructure. You write the function. Someone else runs it.
Using Serverless makes the most sense for one off tasks that can be extracted into a function.
All of the serverless providers give you CLI tools to build and deploy your functions - each provider works in a slightly different way and it is quite time consuming to learn the differences.
This is where serverless.com steps in. It provides an abstraction on top of the providers and gives you an almost uniform workflow regardless of which provider you choose to use.
OpenFaaS stores functions when they're built as Docker images. Once these are built, they'll need to pushed to a Docker registry such as DockerHub.
$ serverless create -t openwhisk-php --path openwhisk_test_service \
--name openwhisk_test_service
$ cd openwhisk_test_service && npm install
The default serverless.yml will need a small addition to
make it web accessible.
service: openwhisk_test_service
provider:
name: openwhisk
runtime: php
functions:
hello:
handler: handler.hello
annotations:
web-export: true
plugins:
- serverless-openwhisk
Then it can be deployed to OpenWhisk with:
$ serverless deploy