Edit on github

#Kubeless HTTP Events

The first type of events that you can create in Kubeless are HTTP events.

When creating HTTP events, Kubeless will create a Kubernetes Service that you can call through Serverless or directly calling the HTTP endpoint.

#Single HTTP Endpoint

If you don't specify the type of event in your serverless.yml Kubeless will create an HTTP endpoint by default:

service: testing-pkg

provider:
  name: kubeless
  runtime: python2.7

plugins:
  - serverless-kubeless

functions:
  hello:
    handler: handler.hello

When deploying this serverless.yml file, Kubeless will create a Kubernetes service with a single endpoint. Calling that HTTP endpoint will trigger the function associated with it.

#Multiple endpoints with Ingress rules

You can also deploy several endpoints in a single serverless.yml file:

service: todos

provider:
  name: kubeless
  runtime: nodejs6

plugins:
  - serverless-kubeless

functions:
  create:
    handler: todos-create.create
    events:
      - http:
          path: /create
  read-all:
    handler: todos-read-all.readAll
    events:
      - http:
          path: /read-all
  read-one:
    handler: todos-read-one.readOne
    events:
      - http:
          path: /read
  update:
    handler: todos-update.update
    events:
      - http:
          path: /update
  delete:
    handler: todos-delete.delete
    events:
      - http:
          path: /delete

If the events HTTP definitions contain a path attribute, when deploying this Serverless YAML definition, Kubeless will create the needed Ingress rules to redirect each of the requests to the right service. You will need to create an Ingress Controller to make use of your Ingress rule(s):

kubectl get ingress
NAME                    HOSTS                   ADDRESS   PORTS     AGE
ingress-1506350705094   192.168.99.100.nip.io             80        28s

Join our monthly newsletter to get the latest Serverless news, updates and happenings.