Kubeless is an open-source Serveless tool that is build on Kubernetes. It is project created by Bitnami. It is part of the Kubernetes Native Serverless Framework. It provides a way for us to deploy and manage applications using the Severless Framework. It has two components the stack containing the likes of Zoo keeper, Controller and Kafka.

Zoo keeper and Kafka serves purposes that are related to triggered events and Controller watches the Function custom endpoints. Kubeless leverages Custom Resource Definition to create what we refer to as Functions. Functions can either be called through sending events to message bus (Kafka) or by HTTP.

I will be setting up Kubeless on Mac using Minikube.

first we will create the Kubeless Namespace.

tunde:~ babatundeolu-isa$ kubectl create ns kubeless
namespace "kubeless" created

next we install Kubeless .

tunde:~ babatundeolu-isa$ export RELEASE=$(curl -s https://api.github.com/repos/kubeless/kubeless/releases/latest | grep tag_name | cut -d '"' -f 4)
tunde:~ babatundeolu-isa$ echo $RELEASE
tunde:~ babatundeolu-isa$ kubectl create -f https://github.com/kubeless/kubeless/releases/download/$RELEASE/kubeless-non-rbac-$RELEASE.yaml
serviceaccount "controller-acct" created
customresourcedefinition.apiextensions.k8s.io "functions.kubeless.io" created
customresourcedefinition.apiextensions.k8s.io "httptriggers.kubeless.io" created
customresourcedefinition.apiextensions.k8s.io "cronjobtriggers.kubeless.io" created
configmap "kubeless-config" created
deployment.apps "kubeless-controller-manager" created
tunde:~ babatundeolu-isa$ kubectl get pods -n kubeless
NAME                                           READY     STATUS    RESTARTS   AGE
kubeless-controller-manager-67fbc78f6d-8b6dh   1/1       Running   0          2m
tunde:~ babatundeolu-isa$ kubectl get deployment -n kubeless
NAME                          DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
kubeless-controller-manager   1         1         1            1           3m
tunde:~ babatundeolu-isa$ kubectl get customresourcedefinition
NAME                          AGE
cronjobtriggers.kubeless.io   3m
functions.kubeless.io         3m
httptriggers.kubeless.io      3m

I have create a python app that will be deployed next by the Function.

tunde:~ babatundeolu-isa$ cat app.py
def hello(event, context):
  print event
  return event['data']

next, we install Kubeless CLI so we can create functions

tunde:~ babatundeolu-isa$ export OS=$(uname -s| tr '[:upper:]' '[:lower:]')
tunde:~ babatundeolu-isa$ curl -OL https://github.com/kubeless/kubeless/releases/download/$RELEASE/kubeless_$OS-amd64.zip && \
>   unzip kubeless_$OS-amd64.zip && \
>   sudo mv bundles/kubeless_$OS-amd64/kubeless /usr/local/bin/
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   615    0   615    0     0    688      0 --:--:-- --:--:-- --:--:--   687
100 7356k  100 7356k    0     0   243k      0  0:00:30  0:00:30 --:--:--  159k
Archive:  kubeless_darwin-amd64.zip
   creating: bundles/kubeless_darwin-amd64/
  inflating: bundles/kubeless_darwin-amd64/kubeless

next we create our function

tunde:~ babatundeolu-isa$ kubeless function deploy test-app --runtime python2.7 --handler app.handler --from-file app.py
INFO[0000] Deploying function...
INFO[0000] Function test-app submitted for deployment
INFO[0000] Check the deployment status executing 'kubeless function ls test-app'

the –runtime species the language the function is written, –handler species the name of the handler, –from-file specifies the name of the file holding the application code.

let us get a list of running functions

tunde:~ babatundeolu-isa$ kubeless function ls
test-app	default  	app.handler	python2.7	            	0/1 NOT READY
tunde:~ babatundeolu-isa$ kubectl get functions
NAME       AGE
test-app   4m
tunde:~ babatundeolu-isa$ kubeless function call test-app --data 'Hello world!'
unction call hello --data 'Hello world!'
Hello world!

Leave a Reply

Your email address will not be published. Required fields are marked *