Kubeless PubSub Events

Kubeless functions can also be registered to listen to PubSub events in a Kafka topic. Kafka (and Zookeeper) are deployed in your Kubernetes cluster as part of the Kubeless deployment.

The function then will be triggered whenever a message is published under a certain topic.

The topic in which the function will be listening is defined in the events section of the serverless.yml:

service: hello

  name: kubeless
  runtime: python2.7

  - serverless-kubeless

    handler: handler.hello
      - trigger: 'hello_topic'

Triggering a function

You can trigger a function by publishing a message under a certain topic.

The Kubeless CLI allows to do this from your command line:

kubeless topic publish --topic hello_topic --data 'hello world!' # push a message into the queue
serverless logs -f hello

# Output
hello world!

You can install the Kubeless CLI tool following the installation guide.

Go to Github