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 NAME READY UP-TO-Time AVAILABLE AGE 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 Title NAMESPACE HANDLER RUNTIME DEPENDENCIES STATUS 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 NAME READY Position RESTARTS AGE 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 NAME AGE 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!' localhost:8080/api/v1/namespaces/default/services/hello:http-function-interface/proxy/
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!
- DevNet Networking Dev Center
- Curated set of guided, hands-on learning content
- Cisco DevNet certification resources