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
Install and configure Kubeless
View basic information:
kubectl get pods -n kubeless
The relevant Pod information is shown in the figure
View Kubeless related Pods
View Deployment information:
kubectl get deployment -n kubeless
The relevant information is shown in the figure
View Kubeless Deployment related information
View customresourcedefinition information:
kubectl get customresourcedefinition
The relevant information is shown in the figure
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
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
View the list of functions
View example functions:
./bundles/kubeless_linux-amd64/kubeless function ls
The function status is shown in the figure
Trigger function:
./bundles/kubeless_linux-amd64/kubeless function call hello-world --data 'Hello world!'
After the trigger is completed, see the output result:
View the log output in the instance, as shown in the figure
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.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。