v0.1.0 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Aug 29, 2017 License: Apache-2.0


Kubeless logo

Build Status

kubeless is a Kubernetes-native serverless framework that lets you deploy small bits of code without having to worry about the underlying infrastructure plumbing. It leverages Kubernetes resources to provide auto-scaling, API routing, monitoring, troubleshooting and more.

Kubeless stands out as we use a ThirdPartyResource (now called Custom Resource Definition) to be able to create functions as custom kubernetes resources. We then run an in-cluster controller that watches these custom resources and launches runtimes on-demand. The controller dynamically injects the functions code into the runtimes and make them available over HTTP or via a PubSub mechanism.

As event system, we currently use Kafka and bundle a kafka setup in the Kubeless namespace for development. Help to support additional event framework like nats.io would be more than welcome.

Kubeless is purely open-source and non-affiliated to any commercial organization. Chime in at anytime, we would love the help and feedback !


Click on the picture below to see a screencast demonstrating event based function triggers with kubeless.




Download kubeless cli from the release page. Then using one of yaml manifests found in the release package to deploy kubeless. It will create a kubeless namespace and a function ThirdPartyResource. You will see a kubeless controller, and kafka, zookeeper statefulset running.

There are several kubeless manifests being shipped for multiple k8s environments (non-rbac, rbac and openshift), please consider to pick up the correct one:

  • kubeless-$RELEASE.yaml is used for non-RBAC Kubernetes cluster.
  • kubeless-rbac-$RELEASE.yaml is used for RBAC-enabled Kubernetes cluster.
  • kubeless-openshift-$RELEASE.yaml is used to deploy Kubeless to OpenShift (1.5+).

For example, this below is a show case of deploying kubeless to a non-RBAC Kubernetes cluster.

$ export RELEASE=0.0.20
$ kubectl create ns kubeless
$ kubectl create -f https://github.com/kubeless/kubeless/releases/download/$RELEASE/kubeless-$RELEASE.yaml

$ 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
kubeless-controller   1         1         1            1           1m

$ kubectl get statefulset -n kubeless
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.


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 python2.7 \
                                --handler test.foobar \
                                --from-file test.py \

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 -> 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 python2.7 \
                                --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


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

Also checkout the functions repository.


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


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

Kubeless uses k8s primitives, there is no additional API server or API router/gateway. Kubernetes users will quickly understand how it works and be able to leverage their existing logging and monitorig setup as well as their troubleshooting skills.


We would love to get your help, feel free to land a hand. We are currently looking to implement the following high level features:

  • Add other runtimes, currently only Python and NodeJS are supported
  • Investigate other messaging bus (e.g nats.io)
  • Instrument the runtimes via Prometheus to be able to create pod autoscalers automatically (e.g use custom metrics not just CPU)
  • Optimize for functions startup time
  • Add distributed tracing (maybe using istio)
  • Break out the triggers and runtimes


Path Synopsis
Serverless framework for Kubernetes.
Serverless framework for Kubernetes.
Kubeless controller binary.
Kubeless controller binary.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL