Skip to content
This repository was archived by the owner on Feb 17, 2024. It is now read-only.

Latest commit

 

History

History
90 lines (66 loc) · 2.03 KB

functions.md

File metadata and controls

90 lines (66 loc) · 2.03 KB

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