Intro to Kubeless

What is it Kubeless

Kubeless is a Kubernetes-native serverless framework that lets you deploy small bits of code (functions) without having to worry about the underlying infrastructure. It is designed to be deployed on top of a Kubernetes cluster and take advantage of all the great Kubernetes primitives. If you are looking for an open source serverless solution that clones what you can find on AWS Lambda, Azure Functions, and Google Cloud Functions, Kubeless is for you!

Kubeless Includes:

  • Support for Python, Node.js, Ruby, PHP, and custom runtimes
  • CLI compliant with AWS Lambda CLI
  • Event triggers using Kafka messaging system and HTTP events
  • Prometheus monitoring of functions calls and function latency by default
  • Serverless Framework plugin

Kubeless Installation

 https://kubeless.io/docs/quick-start/
 https://github.com/kubeless/kubeless/releases
 Installation is made of three steps:
  • Download the kubeless CLI from the release page.
  • Create a kubeless namespace (used by default)
  • Then use one of the YAML manifests found in the release page to deploy kubeless. It will create a functions Custom Resource Definition and launch a controller.

There are several kubeless manifests being shipped for multiple k8s environments (non-rbac, rbac and openshift), pick the one that corresponds to your environment:

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

Example without RBAC k8s: $ export RELEASE=$(curl -s https://api.github.com/repos/kubeless/kubeless/releases/latest | grep tag_name | cut -d ‘”’ -f 4)

$ kubectl create ns kubeless

$ kubectl create -f https://github.com/kubeless/kubeless/releases/download/$RELEASE/kubeless-non-rbac-$RELEASE.yaml

Then:

bash-4.4$ kubectl get customresourcedefinition

NAME AGE

cronjobtriggers.kubeless.io 14m

functions.kubeless.io 14m

httptriggers.kubeless.io 14m

For Deploy Kubeless UI into your cluster

run this:

kubectl create -f https://raw.githubusercontent.com/kubeless/kubeless-ui/master/k8s.yaml -n kubeless

Simple Example - Deploy Python Function

  1. Create test.py file include this code inside it:

    def hello(event, context):

    print event

    return event[‘data’]

  2. You can create it with kubeless cli:

$ kubeless function deploy hello --runtime python2.7 \
                                --from-file test.py \
                                --handler test.hello
INFO[0000] Deploying function...
INFO[0000] Function hello submitted for deployment
INFO[0000] Check the deployment status executing 'kubeless function ls hello'
  • hello: This is the name of the function we want to deploy.
  • --runtime python2.7: This is the runtime we want to use to run our function. Available runtimes are shown in the help information.
  • --from-file test.py: This is the file containing the function code above.
  • --handler test.hello: This specifies the file and the exposed function that will be used when receiving requests. In this example we are using the function hello from the file test.py.
  1. Check the function created: $ kubectl get functions NAME AGE hello 1h
  2. You can then call the function with: $ kubeless function call hello –data ‘Hello world!’ Hello world!
  3. Delete the function:
    • $ kubeless function delete hello
    • $ kubeless function ls

       NAME NAMESPACE HANDLER RUNTIME DEPENDENCIES STATUS
       And nothing here....
      
Thank you for your interest!

We will contact you as soon as possible.

Send us a message

Oops, something went wrong
Please try again or contact us by email at info@tikalk.com