Rechercher

Ce contenu n'est pas disponible dans la langue sélectionnée.

Chapter 11. Subscribing functions to CloudEvents

download PDF

You can subscribe a function to a set of events. This links your function to CloudEvent objects defined by your filters and enables automated responses.

11.1. Subscribing a function to CloudEvents

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

Prerequisites

  • You have installed Knative Eventing on the cluster.
  • You have configured a Knative Broker.
  • You have installed the Knative (kn) CLI.

Procedure

  1. Subscribe the function to events for a given broker by running the following command:

    Example command

    $ kn func subscribe --filter type=com.example.Hello --source my-broker

    Use the --source flag to specify the broker and one or more --filter flags to specify your filters.

    You can also omit the --source flag to use the default broker:

    Example command

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

  2. Deploy the function with Knative Triggers:

    Example command

    $ kn func deploy

    Example output

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

Red Hat logoGithubRedditYoutubeTwitter

Apprendre

Essayez, achetez et vendez

Communautés

À propos de la documentation Red Hat

Nous aidons les utilisateurs de Red Hat à innover et à atteindre leurs objectifs grâce à nos produits et services avec un contenu auquel ils peuvent faire confiance.

Rendre l’open source plus inclusif

Red Hat s'engage à remplacer le langage problématique dans notre code, notre documentation et nos propriétés Web. Pour plus de détails, consultez leBlog Red Hat.

À propos de Red Hat

Nous proposons des solutions renforcées qui facilitent le travail des entreprises sur plusieurs plates-formes et environnements, du centre de données central à la périphérie du réseau.

© 2024 Red Hat, Inc.