GithubHelp home page GithubHelp logo

julianpistorius / kubeless Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vmware-archive/kubeless

1.0 2.0 0.0 37.23 MB

Kubernetes Native Serverless Framework

Home Page: http://kubeless.io

License: Apache License 2.0

Makefile 1.14% Go 74.69% Python 7.31% JavaScript 0.76% Ruby 0.64% Shell 15.45%

kubeless's Introduction

Kubeless logo

Build Status Slack

kubeless is a Kubernetes-native serverless framework. It is currently under active development, the most up-to-date version is HEAD. If you experience any problems during this growing phase please file an issue and we will get back to you as quickly as we can.

There are other solutions, like fission from Platform9, funktion from Fabric8. There is also an incubating project at the ASF: OpenWhisk. We believe however, that Kubeless is the most Kubernetes native of all.

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 and your even triggered functions.

Screencasts

Demo of event based function triggers with Minio.

screencast

Also check our UI project

Usage

Download kubeless from the release page. Then launch the controller. It will create a kubeless namespace and a function ThirdPartyResource. You will see a kubeless controller, and kafka, zookeeper statefulset running.

$ kubectl create ns kubeless
$ kubectl create -f $(curl -s https://api.github.com/repos/kubeless/kubeless/releases/latest | jq -r ".assets[] | select(.name | test(\"yaml\")) | .browser_download_url")

$ kubectl get pods -n kubeless
NAME                                   READY     STATUS    RESTARTS   AGE
kafka-0                                1/1       Running   0          1m
kubeless-controller-3331951411-d60km   1/1       Running   0          1m
zoo-0                                  1/1       Running   0          1m

$ kubectl get deployment -n kubeless
NAME                  DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
kubeless-controller   1         1         1            1           1m

$ kubectl get statefulset -n kubeless
NAME      DESIRED   CURRENT   AGE
kafka     1         1         1m
zoo       1         1         1m

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

$ kubectl get functions

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 get-python --runtime python27 \
                                --handler test.foobar \
                                --from-file test.py \
                                --trigger-http

You will see the function custom resource created:

$ kubectl get functions
NAME          KIND
get-python    Function.v1.k8s.io

You can then call the function with:

$ kubeless function call get-python --data '{"echo": "echo echo"}'
Connecting to function...
Forwarding from 127.0.0.1:30000 -> 8080
Forwarding from [::1]:30000 -> 8080
Handling connection for 30000
{"echo": "echo echo"}

Or you can curl directly, for example (using minikube):

$ curl --data '{"Another": "Echo"}' $(minikube service get-python --url) --header "Content-Type:application/json"
{"Another": "Echo"}

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

Examples

See the examples directory for a list of various examples. Minio, SLACK, Twitter etc ...

Building

Building with go

  • you need go v1.7+
  • 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/kubeless/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 are supported
  • Investigate other messaging bus
  • Instrument the runtimes via Prometheus to be able to create pod autoscalers automatically
  • Optimize for functions startup time

kubeless's People

Contributors

absoludity avatar angelmmiguel avatar anguslees avatar beuno avatar bonifaido avatar dluc avatar james-w avatar jbianquetti-nami avatar jcbsmpsn avatar jojow avatar maxwell92 avatar mkmik avatar ngtuna avatar rosskukulinski avatar sebgoa avatar

Stargazers

 avatar

Watchers

 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.