Knative Eventing code samples

Use the following code samples to help you understand the various use cases for Knative Eventing and Event Sources. Learn more about Knative Eventing and Eventing Sources.

See all Knative code samples in GitHub.

NameDescriptionLanguages
Hello WorldA quick introduction that highlights how to deploy an app using Knative.Go and Python
CloudAuditLogsSourceConfigure a CloudAuditLogsSource resource to read data from Cloud Audit Logs and directly publish to the underlying transport (Pub/Sub), in CloudEvents format.YAML
CloudPubSubSourceConfigure a CloudPubSubSource that fires a new event each time a message is published on a Cloud Pub/Sub topic. This source sends events using a Push-compatible format.YAML
CloudSchedulerSourceConfigure a CloudSchedulerSource resource for receiving scheduled events from Google Cloud Scheduler.YAML
CloudStorageSourceConfigure a CloudStorageSource resource to deliver Object Notifications for when a new object is added to Google Cloud Storage (GCS).YAML
GitHub sourceShows how to wire GitHub events for consumption by a Knative Service.YAML
GitLab sourceShows how to wire GitLab events for consumption by a Knative Service.YAML
Apache Kafka BindingKafkaBinding is responsible for injecting Kafka bootstrap connection information into a Kubernetes resource that embed a PodSpec (as spec.template.spec). This enables easy bootstrapping of a Kafka client.YAML
Apache Kafka ChannelInstall and configure the Apache Kafka Channel as the default Channel configuration for Knative Eventing.YAML
ResetOffsetOnly supported by the Distributed KafkaChannel implementation. The ResetOffset custom resource definition (CRD) exposes the ability to manipulate the location of the ConsumerGroup Offsets in the event stream of a given Knative Subscription. Without the ResetOffset CRD, you must manually stop ConsumerGroups and manipulate the Offsets.YAML
Writing an event source using JavaScriptThis tutorial provides instructions to build an event source in JavaScript and implement it with a ContainerSource or SinkBinding.JavaScript
Parallel with multiple casesCreate a Parallel with two branches.YAML
Parallel with mutually exclusive casesCreate a Parallel with mutually exclusive branches.YAML