About Kubeless is a native serverless framework based on Kubernetes. It allows users to deploy a small amount of code (function) without worrying about the underlying architecture.

Quickly build the Kubeless platform

Introduction to Kubeless

Kubeless is a native serverless framework based on Kubernetes. It allows users to deploy a small amount of code (function) without worrying about the underlying architecture. It is deployed on a Kubernetes cluster and makes full use of the features and resource types of Kubernetes to clone content on AWS Lambda, Azure Functions, and Google Cloud Functions.

The main features of Kubeless can be summarized in the following aspects.

  • Support Python, Node.js, Ruby, PHP, Go, .NET, Ballerina language writing and custom runtime.
  • Kubeless CLI complies with AWS Lambda CLI.
  • Event triggers use Kafka messaging system and HTTP triggers.
  • Prometheus monitors function calls and delays by default.
  • Support Serverless framework plug-in.

Since the features of Kubeless are built on Kubernetes, it is very easy for those familiar with Kubernetes to deploy Kubeless. The main implementation is to convert user-written functions into CRD (Custom Resource Definition) in Kubernetes, and run them in the cluster as a container.

Kubeless deployment

Create a Kubeless service on an existing Kubernetes cluster:

export RELEASE=$(curl -s https://api.github.com/repos/kubeless/kubeless/releases/   latest | grep tag_name | cut -d '"' -f 4)kubectl create ns kubelesskubectl create -f https://github.com/kubeless/kubeless/releases/download/$RELEASE/   kubeless-$RELEASE.yaml

After the creation is successful, as shown in the figure

1.png

Install and configure Kubeless

View basic information:

kubectl get pods -n kubeless

The relevant Pod information is shown in the figure

2.png

View Kubeless related Pods

View Deployment information:

kubectl get deployment -n kubeless

The relevant information is shown in the figure
3.png View Kubeless Deployment related information

View customresourcedefinition information:

kubectl get customresourcedefinition

The relevant information is shown in the figure

4.png

View customresourcedefinition information

Download command line tools

Download the Kubeless tool and unzip it:

export OS=$(uname -s| tr '[:upper:]' '[:lower:]')curl -OL https://github.com/kubeless/kubeless/releases/download/$RELEASE/kubeless_   $OS-amd64.zipunzip kubeless_$OS-amd64.zip

View after decompression:

./bundles/kubeless_linux-amd64/kubeless

As shown in the figure

5.png Use Kubeless command line tool

Experience test

Create the test code helloworld.py:

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

Deployment project:

./bundles/kubeless_linux-amd64/kubeless function deploy hello-world --runtime   python3.6 --from-file helloworld.py --handler helloworld.hello

After the deployment is successful, check the project information:

kubectl get functions

The function list is shown in the figure

6.png

View the list of functions

View example functions:

./bundles/kubeless_linux-amd64/kubeless function ls

The function status is shown in the figure
7.png

Trigger function:

./bundles/kubeless_linux-amd64/kubeless function call hello-world --data 'Hello   world!'

After the trigger is completed, see the output result:

8.png

View the log output in the instance, as shown in the figure

9.png

View logs in the instance

So far, we have successfully created the Kubeless service on the Kubernetes cluster and successfully experienced the Kubeless version of Hello World implementation.

1619b31ea52a3a This article is compiled from "Serverless Engineering Practice From Entry to Advanced", follow the Serverless

Copyright Notice: content of this article is contributed spontaneously by Alibaba Cloud real-name registered users. The copyright belongs to the original author. The Alibaba Cloud Developer Community does not own its copyright and does not assume corresponding legal responsibilities. For specific rules, please refer to the "Alibaba Cloud Developer Community User Service Agreement" and the "Alibaba Cloud Developer Community Intellectual Property Protection Guidelines". If you find suspected plagiarism in this community, fill in the infringement complaint form to report it. Once verified, the community will immediately delete the suspected infringing content.

阿里云开发者
3.2k 声望6.3k 粉丝

阿里巴巴官方技术号,关于阿里巴巴经济体的技术创新、实战经验、技术人的成长心得均呈现于此。


引用和评论

0 条评论