Serverless with Kubeless – DevOps Series, Part 18

Welcome back again to our on-going series about hands-on with serverless, hope it really is becoming enjoyed by you! For the post today we shall explore another interesting FaaS runtime motor: Kubeless.

So allow’s begin!

Identical to with other FaaS motors you will have to install its CLI first. For instance with OSX:

export Operating system=$(uname -s| tr '[:higher:]' '[:lower:]')
curl -OL https://github.com/kubeless/kubeless/releases/download/$Discharge/kubeless_$OS-amd64.zip && 
unzip kubeless_$OS-amd64.zip && 
sudo mv bundles/kubeless_$OS-amd64/kubeless /usr/local/bin/

Now you require to make a new namespace which will be used designed for Kubeless:

kubectl create ns kubeless

And finally deploy the most recent Kubeless release in the brand new namespace:

export Launch=$(curl -s https://api.github.com/repos/kubeless/kubeless/releases/newest | grep tag_name | reduce -d '"' -f 4)
kubectl create -f https://github.com/kubeless/kubeless/releases/download/$Discharge/kubeless-$RELEASE.yaml

Verify the deployment is 0k with:

$ kubectl obtain deployment -n kubeless
kubeless-controller-supervisor 1/1 1 1 4m51s

Kubeless is fully deployed within your k8s cluster&hellip now; that has been easy!

Let’s create our first function today, for instance using python. Develop a document called check.py you need to include this simple content:

def hello(occasion, context):
print event
return event['data']

As possible seen by you is an extremely simple system that returns exactly the same data it receives.

Allow’s deploy a fresh function running that program code with the next command:

kubeless function deploy hello --runtime python2.7 
--from-file test.py 
--handler test.hi there

Wait until it turns up as READY:

$ kubeless functionality ls hello
hello default check.hello python2.7 1/1 READY

Your function is deployed on Kubeless!

You can view the pod working in the default namespace:

$ kubectl get pods
hi there-55f6478db6-d72fz 1/1 Running 0 4m49s

One huge difference with Kubeless is that through the installation process it generates a fresh Custom Resource Definition (CRD) indigenous to k8s, in order that functions could be managed like regular k8s objects:

$ kubectl get functions
hello 9m25s

OK, allow’s notice if our new functionality works, running:

$ kubeless function contact hello --data 'Hello world'
Hello world

Nice, it functions fine!

For the Kubeless deployment we didn’t configure any accessible Ip with a LoadBalancer service externally, so we shall test HTTP access using kubectl proxy from our workstation:

kubectl proxy -p 8080 &
curl -L --data 'Hello there!' 

Fantastic, our perform is designed for everyone to gain access to it now. Well done!

See a person in my own next post to keep exploring other serverless motors it is possible to run on kubernetes, keep tuned in!

Any related questions or comments please i want to know within the comments section below, Twitter or LinkedIn.

Related resources:

The post Serverless with Kubeless – DevOps Series, Part 18 appeared very first on Cisco Blogs.

%d bloggers like this: