Code Monkey home page Code Monkey logo

kubeless's Introduction

Kubeless

kubeless is a proof of concept to develop a serverless framework for Kubernetes.

There are other solutions, like fission from Platform9, funktion from Fabric8. There is also an incubating project at the ASF: OpenWhisk.

Kubeless stands out as we use a ThirdPartyResource to be able to create functions as custom resources. We then run an in-cluster controller that watches these custom resources and launches runtimes on-demand. These runtimes, dynamically inject the functions and make them available over HTTP or via a PubSub mechanism.

For PubSub we use Kafka. Currently we start Kafka and Zookeeper in a non-persistent setup. With kubeless you can create topics, and publish events that get consumed by the runtime.

Screencasts

From the December 8th 2016 Kubernetes Community meeting

screencast

Usage

Download kubeless from the release page. Then launch the controller. It will ask you if you are OK to do it. It will create a kubeless namespace and a function ThirdPartyResource. You will see a kubeless controller and a kafka controller running.

$ kubeless install
We are going to install the controller in the kubeless namespace. Are you OK with this: [Y/N]
Y
INFO[0002] Initializing Kubeless controller...           pkg=controller
INFO[0002] Installing Kubeless controller into Kubernetes deployment...  pkg=controller
INFO[0002] Kubeless controller installation finished!    pkg=controller
INFO[0002] Installing Message Broker into Kubernetes deployment...  pkg=controller
INFO[0002] Message Broker installation finished!         pkg=controller

$ kubectl get pods --namespace=kubeless
NAME                                   READY     STATUS              RESTARTS   AGE
kafka-controller-2158053540-a7n0v      0/2       ContainerCreating   0          12s
kubeless-controller-1801423959-yow3t   0/2       ContainerCreating   0          12s

$ kubectl get thirdpartyresource
NAME             DESCRIPTION                                     VERSION(S)
function.k8s.io   Kubeless: Serverless framework for Kubernetes   v1

$ kubectl get functions

Note We provide --kafka-version flag for specifying the kafka version will be installed and --controller-image in case you are willing to install your customized Kubeless controller. Without the flags, we will install the newest release of bitnami/kubeless-controller and the latest wurstmeister/kafka. Check kubeless install --help for more detail.

You are now ready to create functions. Then you can use the CLI to create a function. Functions have two possible types:

  • http trigger (function will expose an HTTP endpoint)
  • pubsub trigger (function will consume event on a specific topic)

HTTP function

Here is a toy:

def foobar(context):
   print context.json
   return context.json

You create it with:

$ kubeless function deploy test --runtime python27 \
                              --handler test.foobar \
                              --from-file test.py \
                              --trigger-http

You will see the function custom resource created:

$ kubectl get functions
NAME      LABELS    DATA
test      <none>    {"apiVersion":"k8s.io/v1","kind":"Function","metadat...

PubSub function

Messages need to be JSON messages. A function can be as simple as:

def foobar(context):
   print context.json
   return context.json

You create it the same way than an HTTP function except that you specify a --trigger-topic.

$ kubeless function deploy test --runtime python27 \
                              --handler test.foobar \
                              --from-file test.py \
                              --trigger-topic <topic_name>

Other commands

You can delete and list functions:

$ kubeless function delete <function_name>
$ kubeless function ls

You can create, list and delete PubSub topics:

$ kubeless topic create <topic_name>
$ kubeless topic delete <topic_name>
$ kubeless topic ls

To test your endpoints you can call the function directly with the kubeless CLI:

$ kubeless function call test --data '{"kube":"coodle"}'

Building

Building with go

  • you need go v1.5 or later.
  • if your working copy is not in your GOPATH, you need to set it accordingly.
  • we provided Makefile.
$ make binary

You can build kubeless for multiple platforms with:

$ make binary-cross

Download kubeless package

$ go get -u github.com/bitnami/kubeless

Roadmap

This is still currently a POC, feel free to land a hand. We need to implement the following high level features:

  • Add other runtimes, currently only Python and NodeJS is supported
  • Deploy Kafka and Zookeeper using StatefulSets for persistency
  • Instrument the runtimes via Prometheus to be able to create pod autoscalers automatically

kubeless's People

Contributors

ngtuna avatar sebgoa avatar beuno avatar jojow avatar rosskukulinski avatar anguslees avatar dluc avatar james-w avatar mkmik avatar maxwell92 avatar

Watchers

Vinny Wang avatar James Cloos avatar  avatar

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.