diff --git a/docs/spec/README.md b/docs/spec/README.md index 1f1c33489dc..06ebb54343c 100644 --- a/docs/spec/README.md +++ b/docs/spec/README.md @@ -1,30 +1,23 @@ # Knative Eventing API spec This directory contains the specification of the Knative Eventing API, which is -implemented in [`channels.knative.dev`](/pkg/apis/channels/v1alpha1), -[`feeds.knative.dev`](/pkg/apis/feeds/v1alpha1) and -[`flows.knative.dev`](/pkg/apis/flows/v1alpha1) and verified via [the e2e -test](/test/e2e). +implemented in [`eventing.knative.dev`](/pkg/apis/eventing/v1alpha1) and +verified via [the e2e test](/test/e2e). **Updates to this spec should include a corresponding change to the API -implementation for [channels](/pkg/apis/channels/v1alpha1), -[feeds](/pkg/apis/feeds/v1alpha1) or [flows](/pkg/apis/feeds/v1alpha1) and [the -e2e test](/test/e2e).** +implementation for [eventing](/pkg/apis/eventing/v1alpha1) and [the e2e +test](/test/e2e).** Docs in this directory: -* [Motivation and goals](motivation.md) -* [Resource type overview](overview.md) - +- [Motivation and goals](motivation.md) +- [Resource type overview](overview.md) +- [Interface contracts](interfaces.md) +- [Object model specification](spec.md) + - \ No newline at end of file +See the [Knative Eventing Docs +Architecture](https://github.com/knative/docs/blob/master/eventing/README.md#architecture) +for more high level details. diff --git a/docs/spec/images/overview-reference.dot b/docs/spec/images/overview-reference.dot deleted file mode 100644 index 5d049b11ee8..00000000000 --- a/docs/spec/images/overview-reference.dot +++ /dev/null @@ -1,33 +0,0 @@ -// This is the overview graph for object refrences in the control plane. -// -// To reproduce the PNG, run the following: -// $ dot -Tpng overview-reference.dot -o overview-reference.png -// -digraph G { - ordering = out; - rankdir = LR; - - node [shape=rectangle; width=1.25; height=.5; fixedsize=true;] - - subgraph cluster_A { - Source -> EventType [dir=back]; - color=white; - {rank = same; Source; EventType;} - } - - subgraph cluster_C { - Feed; - Channel - Subscription; - label = "Flow"; - } - EventType -> Feed [dir=back]; - Feed -> Channel; - - Subscription -> Service; - Channel -> Subscription [dir=back]; - - Bus -> Channel [dir=back]; - - {rank = max; Service;} -} diff --git a/docs/spec/images/overview-reference.png b/docs/spec/images/overview-reference.png deleted file mode 100644 index 69d363eeeb2..00000000000 Binary files a/docs/spec/images/overview-reference.png and /dev/null differ diff --git a/docs/spec/images/resource-types-overview.svg b/docs/spec/images/resource-types-overview.svg new file mode 100644 index 00000000000..943ac7d96f0 --- /dev/null +++ b/docs/spec/images/resource-types-overview.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docs/spec/images/resource-types-provisioner.svg b/docs/spec/images/resource-types-provisioner.svg new file mode 100644 index 00000000000..53426f57f04 --- /dev/null +++ b/docs/spec/images/resource-types-provisioner.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docs/spec/interfaces.md b/docs/spec/interfaces.md new file mode 100644 index 00000000000..3142554fb24 --- /dev/null +++ b/docs/spec/interfaces.md @@ -0,0 +1,91 @@ +# Interface Contracts + +## Subscribable + +A **Subscribable** resource contains a list of subscribers and is responsible +for delivering events to each of them. Subscriptions only allow Channels to be +Subscribable (via `spec.from` on the Subscription) at the moment, but this may +be revisited with future experience. _Channel_ as the target of a +_Subscription_'s `from` field. + + +### Control Plane + +The **Subscribable** resource stores a list of resolved _Subscriptions_ in the +resource's `spec.subscribers` field. The Subscription Controller is responsible +for resolving any ObjectReferences (such as _call_ and _result_) in the +_Subscription_ to network addresses. + +### Data Plane + +**Subscribable** resources will attempt delivery to each of the _subscribers_ +at least once, and retry if the subscriber returns errors. + + + +--- + +## Targetable + +A **Targetable** resource represents an endpoint that receives events and +optionally returns events to forward downstream. One example of a _Targetable_ +is a function. + +### Control Plane + +A **Targetable** resource MUST expose a _status.targetable.domainInternal_ +field. The _domainInternal_ value is an internal domain name that is capable of +receiving event deliveries. _Targetable_ resources may be referenced in the +_call_ section of a _Subscription_. + +### Data Plane + +The **Targetable** resource receives one event and returns zero or more events +in response. The returned events are not required to be related to the received +event. The _Targetable_ should return a successful response if the event was +processed successfully. + +The _Targetable_ is not responsible for ensuring successful delivery of any +received or returned event. It may receive the same event multiple times even +if it previously indicated success. + +--- + +## Sinkable + +A **Sinkable** resource receives events and takes responsibility for further +delivery. Unlike _Targetable_, a _Sinkable_ cannot return events in its +response. One example of a _Sinkable_ is a _Channel_ as the target of a +_Subscription_'s _result_ field. + + + +### Control Plane + +A **Sinkable** resource MUST expose a _status.sinkable.domainInternal_ field. +The _domainInternal_ value is an internal domain name that is capable of +receiving event deliveries. _Sinkable_ resources may be referenced in the +_result_ section of a _Subscription_, and also by other custom resources acting as an event Source. + +### Data Plane + +A **Sinkable** resource will only respond to requests with success of failure. +Any payload (including a valid CloudEvent) returned to the sender will be +ignored. It may receive the same event multiple times even if it previously +indicated success. + +--- + +_Navigation_: + +- [Motivation and goals](motivation.md) +- [Resource type overview](overview.md) +- **Interface contracts** +- [Object model specification](spec.md) diff --git a/docs/spec/motivation.md b/docs/spec/motivation.md index f1f6d4f2e58..6417f11b16c 100644 --- a/docs/spec/motivation.md +++ b/docs/spec/motivation.md @@ -25,11 +25,26 @@ decoupled way. Kubernetes has no primitives related to event processing, yet this is an essential component in serverless workloads. Eventing introduces high-level -primitives for event production and delivery with a focus on push over HTTP. If -a new event source or type is required of your application, the effort required -to plumb them into the existing eventing framework will be minimal and will -integrate with CloudEvents middleware and message consumers. +primitives for event production and delivery with an initial focus on push over +HTTP. If a new event source or type is required of your application, the effort +required to plumb them into the existing eventing framework will be minimal and +will integrate with CloudEvents middleware and message consumers. -The Knative Eventing API is intended to operate independently, and interop +Knative eventing implements common components of an event delivery ecosystem: +enumeration and discovery of event sources, configuration and management of +event transport, and declarative binding of events (generated either by storage +services or earlier computation) to further event processing and persistence. + +The Knative Eventing API is intended to operate independently, and interoperate well with the [Serving API](https://github.com/knative/serving) and [Build API](https://github.com/knative/build). + + +--- + +_Navigation_: + +- **Motivation and goals** +- [Resource type overview](overview.md) +- [Interface contracts](interfaces.md) +- [Object model specification](spec.md) diff --git a/docs/spec/overview.md b/docs/spec/overview.md index 9dd1121e912..f111164d321 100644 --- a/docs/spec/overview.md +++ b/docs/spec/overview.md @@ -1,70 +1,93 @@ -# Resource Groups - -Knative Eventing API is grouped into _Channels_, _Feeds_ and _Flows_: +# Resource Types -* _Channels_ define an abstraction between the eventing infrastructure and the - consumption and production of the events. +The API defines and provides a complete implementation for +[Subscription](spec.md#kind-subscription), and abstract resource definitions +for [Channels](spec.md#kind-channel) and +[ClusterChannelProvisioners](spec.md#kind-clusterchannelprovisioner) which may +be fulfilled by multiple backing implementations (much like the Kubernetes +Ingress resource). -* _Feeds_ bridge the event source into the eventing framework. +With extendibility and compostability as a goal of Knative Eventing, the +eventing API defines several resources that can be reduced down to a well +understood contracts. These eventing resource interfaces may be fulfilled by +other Kubernetes objects and then composed in the same way as the concreate +objects. The interfaces are ([Sinkable](interfaces.md#sinkable), +[Subscribable](interfaces.md#Subscribable), +[Targetable](interfaces.md#targetable)). For more details, see +[Interface Contracts](interfaces.md). -* _Flows_ abstract the path of an event from a source takes to reach an event - consumer. +- A **Subscription** describes the transformation of an event and optional + forwarding of a returned event. -Typically, _Feeds_ perform out-of-cluster provisioning, while _Channels_ are -within-cluster management of event delivery. _Flows_ is a higher order wrapper -used to connect event producers directly with event consumers leveraging -_Feeds_ and _Channels_. +- A **Channel** provides event persistance and fanout of events from a + well-known input address to multiple outputs described by _Subscriptions_. -# Resource Types + -The primary resources in the Knative Eventing _Feeds_ API are EventSource, -EventType and Feed: +![Resource Types Overview](images/resource-types-overview.svg) -* **EventSource**, an archetype of an event producer. +- **ClusterChannelProvisioners** implement strategies for realizing backing resources + for different implementations of _Channels_ currently active in the eventing + system. -* **EventType**, the schema for an event. + -* **Feed**, the association between the output of an event producer to the - input of an event consumer. +Resource Types ClusterChannelProvisioners -An example _Feeds_ setup: GitHub would be the _EventSource_, a Pull Request -notification would be the _EventType_ and the _Feed_ describes the _org/repo_, -credentials, the specific _EventType_ and the consumer of the _Feed_ events. +Sources are defined by independent CRDs that can be installed into a cluster. +For more information see [Knative Eventing +Sources](https://github.com/knative/eventing-sources). +## Subscription -The primary resources in the Knative Eventing _Channels_ API are Channel, -Subscription and Bus: +**Subscriptions** describe a flow of events from one _Channel_) to the next +Channel\* through transformations (such as a Knative Service which processes +CloudEvents over HTTP). A _Subscription_ controller resolves the addresses of +transformations (`call`) and destination storage (`result`) through the +_Targetable_ and _Sinkable_ interface contracts, and writes the resolved +addresses to the _Channel_ in the `from` reference. _Subscriptions_ do not need +to specify both a transformation and a storage destination, but at least one +must be provided. -* **Channel**, a named endpoint which accepts and forwards events. +All event delivery linkage from a **Subscription** is 1:1 – only a single +`from`, `call`, and `result` may be provided. -* **Bus**, an implementation of an event delivery mechanism. +For more details, see [Kind: Subscription](spec.md#kind-subscription). -* **Subscription**, an expressed interest in events from a _Channel_ to be - delivered to an HTTP endpoint. +## Channel -An example _Channels_ setup: A _Channel_ has declared it is implemented by a -PubSubBusImpl. The PubSubBusImpl _Bus_ accepts input from an event producer -that is pushing events to the _Channel_. The _Bus_ also watches for -_Subscription_(s) on the _Channel_ and delivers the events accepted to the -consumer. +**Channel** provides an at least once event delivery mechanism which can fan +out received events to multiple destinations via _Subscriptions_. A _Channel_ +has a single inbound _Sinkable_ interface which may accept events from multiple +_Subscriptions_ or even direct delivery from external systems. Different +_Channels_ may implement different degrees of persistence. Event delivery order +is dependent on the backing implementation of the _Channel_ provided by the +_ClusterChannelProvisioner_. +Event selection on a _Channel_ is 1:N – a single _Channel_ may fan out to +multiple _Subscriptions_. -The _Flows_ API implements a single resource, Flow: +See [Kind: Channel](spec.md#kind-channel). -* **Flow**, is an abstraction of the connection between an event producer to - the event consumer leveraging _Feed_s and _Channels_. +## ClusterChannelProvisioner +**ClusterChannelProvisioner** catalogs available implementations of _Channels_. +_ClusterChannelProvisioners_ hold a JSON Schema that is used to validate the +_Channel_ input arguments. _ClusterChannelProvisioners_ make it possible to +provide cluster wide defaults for the _Channels_ they provision. -An example _Flows_ setup: The _Flow_ describes the same properties as the _Feed_ -except the target could be a _Service.serving.knative.dev_ and the _Flow_ will -create the _Channel_, _Feed_, and _Subscription_ for the event to flow from -event producer (GitHub) to event consumer (MyService). +_ClusterChannelProvisioners_ do not directly handle events. They are 1:N with +_Channels_. +For more details, see [Kind: +ClusterChannelProvisioner](spec.md#kind-clusterchannelprovisioner). -![Object Model](images/overview-reference.png) -See the [Knative Eventing Docs -Architecture](https://github.com/knative/docs/blob/master/eventing/README.md#architecture) -for more details. +--- +_Navigation_: +- [Motivation and goals](motivation.md) +- **Resource type overview** +- [Interface contracts](interfaces.md) +- [Object model specification](spec.md) diff --git a/docs/spec/spec.md b/docs/spec/spec.md new file mode 100644 index 00000000000..2450d41cf5a --- /dev/null +++ b/docs/spec/spec.md @@ -0,0 +1,183 @@ +# Object Model + +Knative ships with several objects which implement useful sets of +[interfaces](interfaces.md). It is expected that additional objects which +implement these interfaces will be added over time. For context, see the +[overview](overview.md) and [motivations](motivation.md) sections. + +These are Kubernetes resources that been introduced using Custom Resource +Definitions. They will have the expected _ObjectMeta_, _Spec_, _Status_ fields. +This document details our _Spec_ and _Status_ customizations. + +- [Channel](#kind-channel) +- [Subscription](#kind-subscription) +- [ClusterChannelProvisioner](#kind-clusterchannelprovisioner) + +## kind: Channel + +### group: eventing.knative.dev/v1alpha1 + +_A Channel logically receives events on its input domain and forwards them to +its subscribers._ + +### Object Schema + +#### Spec + +| Field | Type | Description | Limitations | +| ------------- | ---------------------------------- | -------------------------------------------------------------------------- | -------------------------------------- | +| provisioner\* | ProvisionerReference | The name of the provisioner to create the resources that back the Channel. | Immutable. | +| arguments | runtime.RawExtension (JSON object) | Arguments to be passed to the provisioner. | | +| subscribers | ChannelSubscriberSpec[] | Information about subscriptions used to implement message forwarding. | Filled out by Subscription Controller. | + +\*: Required + +#### Metadata + +##### Owner References + +- Owned (non-controlling) by the ClusterChannelProvisioner used to provision + the Channel. + +#### Status + +| Field | Type | Description | Limitations | +| ---------- | ---------- | --------------------------------------------------------------------------------------------------------------------------- | ----------- | +| sinkable | Sinkable | Address to the endpoint as top-level domain that will distribute traffic over the provided targets from inside the cluster. | | +| conditions | Conditions | Channel conditions. | | + +##### Conditions + +- **Ready.** True when the Channel is provisioned and ready to accept events. +- **Provisioned.** True when the Channel has been provisioned by a controller. + +#### Events + +- Provisioned +- Deprovisioned + +### Life Cycle + +| Action | Reactions | Limitations | +| ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------- | +| Create | The ClusterChannelProvisioner referenced will take ownership of the Channel and begin provisioning the backing resources required for the Channel depending on implementation. | Only one ClusterChannelProvisioner is allowed to be the Owner for a given Channel. | +| Update | The ClusterChannelProvisioner will synchronize the Channel backing resources to reflect the update. | | +| Delete | The ClusterChannelProvisioner will deprovision the backing resources if no longer required depending on implementation. | | + +--- + +## kind: Subscription + +### group: eventing.knative.dev/v1alpha1 + +_Describes a linkage between a Channel and a Targetable and/or Sinkable._ + +### Object Schema + +#### Spec + +| Field | Type | Description | Limitations | +| ------------------ | -------------- | ---------------------------------------------------------------------------- | ------------------ | +| from\* | ObjectRef | The originating _Subscribable_ for the link. | Must be a Channel. | +| call1 | EndpointSpec | Optional processing on the event. The result of call will be sent to result. | | +| result1 | ResultStrategy | The continuation for the link. | | + +\*: Required + +1: At Least One(call, result) + +#### Metadata + +##### Owner References + +- If a resource controller created this Subscription: Owned by the originating + resource. + +##### Conditions + +- **Ready.** +- **FromReady.** +- **Resolved.** True if `from`, `call`, and `result` all resolve into valid object references which implement the appropriate spec. + +#### Events + +- PublisherAcknowledged +- ActionFailed + +### Life Cycle + +| Action | Reactions | Limitations | +| ------ | ------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | +| Create | The subscription controller adds the resolved URIs of `call` and `result` to the `subscribers` field in the `from` _Subscribable_ resource. | | +| Update | | | +| Delete | | | + +--- + +## kind: ClusterChannelProvisioner + +### group: eventing.knative.dev/v1alpha1 + +_Describes an abstract configuration of a Source system which produces events +or a Channel system that receives and delivers events._ + +### Object Schema + +#### Spec + +| Field | Type | Description | Limitations | +| ---------- | ---------------------------------- | ------------------------------------------------------------------------------------------------- | ---------------- | +| parameters | runtime.RawExtension (JSON object) | Description of the arguments able to be passed by the provisioned resource (not enforced in 0.1). | JSON Schema | + +\*: Required + +#### Status + +| Field | Type | Description | Limitations | +| ---------- | ---------- | ------------------------------------ | ----------- | +| conditions | Conditions | ClusterChannelProvisioner conditions | | + +##### Conditions + +- **Ready.** + +#### Events + +- Resource Created. +- Resource Removed. + +--- + +## Shared Object Schema + +### ProvisionerReference + +| Field | Type | Description | Limitations | +| ----- | --------------- | ----------- | ----------- | +| ref\* | ObjectReference | | | + +\*: Required + +### EndpointSpec + +| Field | Type | Description | Limitations | +| --------------------- | --------------- | ----------- | -------------------------- | +| targetRef1 | ObjectReference | | Must adhere to Targetable. | +| dnsName1 | String | | | + +1: One of (targetRef, dnsName), Required. + +### ChannelSubscriberSpec + +| Field | Type | Description | Limitations | +| ----------- | ------ | -------------------------------------------- | -------------- | +| callableURI | String | The URI name of the endpoint for the call. | Must be a URL. | +| sinkableURI | String | The URI name of the endpoint for the result. | Must be a URL. | + +### ResultStrategy + +| Field | Type | Description | Limitations | +| -------- | --------- | -------------------------------------- | ------------------ | +| target\* | ObjectRef | The continuation Channel for the link. | Must be a Channel. | + +\*: Required