mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
2.0 KiB
2.0 KiB
Read this on the main serverless docs site
Kubeless - Functions
If you are using Kubeless as a provider, all functions inside the service are Kubernetes Function.v1.k8s.io objects.
Configuration
All of the Kubeless Functions in your serverless service can be found in serverless.yml under the functions property.
# serverless.yml
service: my-service
provider:
name: kubeless
runtime: python2.7
plugins:
- serverless-kubeless
functions:
# The top name will be the name of the Function object
# and the K8s service object to get a request to call the function
hello:
# The function to call as a response to the HTTP event
handler: handler.hello
The handler property points to the file and module containing the code you want to run in your function.
// handler.py
import json
def hello(request):
body = {
"message": "Go Serverless v1.0! Your function executed successfully!",
"input": request.json
}
response = {
"statusCode": 200,
"body": json.dumps(body)
}
return response
You can add as many functions as you want within this property.
# serverless.yml
service: my-service
provider:
name: kubeless
runtime: python2.7
plugins:
- serverless-kubeless
functions:
hello_one:
handler: handler.hello_one
hello_two:
handler: handler.hello_two
Runtimes
The Kubeless provider plugin supports the following runtimes.
- Node.js
- Python
- Ruby
Please see the following repository for sample projects using those runtimes:
https://github.com/serverless/serverless-kubeless/tree/master/examples