Fission – New Serverless Framework for Kubernetes

Categories

Fission.io is an open-source framework for serverless functions on Kubernetes, created by Platform9. While it’s still in early alpha (meaning production use is not advised at this juncture), Fission can turn any cluster into a system for delivering serverless or AWS Lambda-style app architecture on your own hardware or with a managed Kubernetes service.

Fission keeps both Kubernetes and Docker abstracted away (although it can extend to both) so that developers can direct their focus to software rather than getting bogged down in infrastructural details.

Fission’s core is implemented in Go and it’s extensible to any language. Out of the box, it currently supports both Python and NodeJS, but Fission notes that more languages are on their way with the goal of eventually becoming as language-agnostic as possible.

Fission is built atop Kubernetes and works in conjunction with any Kubernetes cluster, which speaks to how foundational Google’s open-source orchestrator for container clusters is becoming. Working with Kubernetes allows Fission functions to interoperate with conventional microservices. This also means that anything developers do for operations on their Kubernetes cluster also assists with operations in their Fission deployment.

Fission is also part and parcel of the broad trend toward serverless, in which developers can deploy and run code on demand without having to maintain the backend or think about deployment, routing, scalability, and availability.

Core Fission Concepts

Function: A piece of code that follows the fission function interface.

Environment: Essentially a container with a webserver and dynamic loader that holds the language- and runtime-specific parts of running a function.

Trigger: Something that maps functions to events.

Developers can write short-lived functions that use Fission’s API in any language (analogous to AWS Lambda), and map them to event triggers, such as an HTTP route. When an HTTP request is made to the route, the function is loaded into a container and run in an environment. The functions can be deployed instantly using one command.

Fission provides prebuilt containers obviating the need to build app containers or manage Docker registries. Upon launch, Fission fabricates a group of “pre-warmed containers”, each with a small dynamic loader and ready to receive functions. This means that “cold start” latencies are about 100 milliseconds on average, though that figure likely varies depending on deployment and hardware.

As an aside, Fission notes that support for other types of triggers is forthcoming, such as timers and Kubernetes events. Subscribing functions to Kubernetes events will allow developers to write custom automation for Kubernetes infrastructure.

Usage

Here’s how Fission works:

# Add the stock NodeJS env to your Fission deployment
 $ fission env create –name nodejs –image fission/node-env

 # A javascript one-liner that prints “hello world”
 $ echo ‘module.exports = function(context, callback) { callback(200, “Hello, world!\n”); }’ > hello.js  

 # Upload your function code to fission
 $ fission function create –name hello –env nodejs –code hello.js

 # Map GET /hello to your new function
 $ fission route create –method GET –url /hello —function hello

 # Run the function.  This takes about 100msec the first time.
 $ curl http://$FISSION_ROUTER/hello
 Hello, world!

Compiling Fission

You’ll only need to compile if you’re making Fission changes. It requires Go installation, the glide dependency management tool, and Docker for building images.

The server side is compiled as a binary, or “fission-bundle”, which holds the controller, poolmgr, and router. The fission-bundle invokes the right one based on command-line arguments, according to the Fission project description on Github.

To build the fission-bundle, clone this repo and then, from the top-level directory:

# Get dependencies
 $ glide install

 # Build fission server and an image
 $ pushd fission-bundle
 $ ./build.sh

 # Edit push.sh to point to your registry
 $ $EDITOR push.sh
 $ ./push.sh
 $ popd

 # To install, update fission.yaml to point to your compiled image
 $ $EDITOR fission.yaml
 $ kubectl create -f fission.yaml

If you’re changing the command-line interface:

# Build Fission CLI
 $ cd fission && go install

Sources

 

Scroll to Top