Skip to content

Subscribe functions to CloudEvents

Prerequisites

  • Knative Eventing installed on the cluster

Procedure

The subscribe command will connect the function to a set of events, matching a series of filters for Cloud Event metadata and a Knative Broker as the source of events, from where they are consumed.

To subscribe the function to events for a given broker, run the following command:

func subscribe --filter type=com.example --filter extension=my-extension-value --source my-broker

To subscribe the function to events for the default broker, run the following command:

func subscribe --filter type=com.example --filter extension=my-extension-value

To subscribe the function to events for a given broker, run the following command:

kn func subscribe --filter type=com.example --filter extension=my-extension-value --source my-broker

To subscribe the function to events for the default broker, run the following command:

kn func subscribe --filter type=com.example --filter extension=my-extension-value

Deployment with Triggers

When invoking func deploy the CLI will create Knative Triggers for the function.

Deploy the function with Triggers by running the command inside the project directory:

func deploy

Deploy the function with Triggers by running the command inside the project directory:

kn func deploy

Expected output

    🙌 Function image built: <registry>/hello:latest
    🎯 Creating Triggers on the cluster
    ✅ Function deployed in namespace "default" and exposed at URL:
    http://hello.default.127.0.0.1.sslip.io

We use analytics and cookies to understand site traffic. Information about your use of our site is shared with Google for that purpose. Learn more.

× OK