Kubeless is a native serverless framework based on Kubernetes. It allows users to deploy small amounts of code (functions) without worrying about the underlying architecture.
Build the Kubeless platform quickly
Kubeless profile
Kubeless is a native serverless framework based on Kubernetes. It allows users to deploy small amounts of code (functions) without worrying about the underlying architecture. It is deployed on top of the Kubernetes cluster and takes full advantage of Kubernetes’ features and resource types 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 conforms to AWS Lambda CLI.
- Event triggers use the Kafka messaging system and HTTP triggers.
- Prometheus monitors function calls and delays by default.
- Support for the Serverless framework plug-in.
Because the features of Kubeless are built on top of Kubernetes, it is very easy for people familiar with Kubernetes to deploy Kubeless. Its main implementation is to convert user-written functions into CRD (Custom Resource Definition) in Kubernetes, and run in the cluster in the way of containers.
Kubeless deployment
Create Kubeless service on 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.yamlCopy the code
After successful creation, the following figure is displayed
Install and configure Kubeless
View basic information:
kubectl get pods -n kubeless
Copy the code
The related Pod information is shown in the figure below
View Kubeless related pods
View Deployment information:
kubectl get deployment -n kubeless
Copy the code
The related information is shown in the figure
View information about Kubeless Deployment
View customResourceDefinition information:
kubectl get customresourcedefinition
Copy the code
The related information is shown in the figure
View customResourceDefinition information
Download the command line tool
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
Copy the code
View after decompression:
./bundles/kubeless_linux-amd64/kubeless
Copy the code
The details are shown in the figure
Use the Kubeless command line tool
Acceptance testing
Create test code helloworld.py:
def hello(event, context): print(event) return event['data']
Copy the code
Deployment project:
/bundles/kubeless_linux-amd64/kubeless function deploy hello-world -- Runtime python3.6 --from-file helloworld.py --handler helloworld.helloCopy the code
After successful deployment, view project information:
kubectl get functions
Copy the code
The list of functions is shown below
View the list of functions
View the example function:
./bundles/kubeless_linux-amd64/kubeless function ls
Copy the code
The function state is shown in the figure
Trigger function:
./bundles/kubeless_linux-amd64/kubeless function call hello-world --data 'Hello world! 'Copy the code
When the trigger is complete, you see the output:
View the log output from the example, as shown
View logs in the instance
At this point, we have successfully created the Kubeless service on the Kubernetes cluster and are experiencing the Hello World implementation of the Kubeless version without a hitch.
The original link
This article is the original content of Aliyun and shall not be reproduced without permission.