Slide 1

Slide 1 text

cloudevents 2020-11-11 Claud Choi @ Buzzvil

Slide 2

Slide 2 text

Event ● In programming and software design, an event is an action or occurrence recognized by software. ● Events are everywhere. ● But, event publishers tend to describe events differently.

Slide 3

Slide 3 text

Existing event formats

Slide 4

Slide 4 text

Problem ● Developers should constantly re-learn how to consume events.

Slide 5

Slide 5 text

CloudEvents ● A specification for describing event data in a common way ● Provide interoperability across services, platforms and systems. ● CNCF incubating project ○ v1.0 released on October 24, 2019 Protocol Message Event Context Data Occurrence

Slide 6

Slide 6 text

Occurrence ● Capture of a statement of fact during the operation of a software system ○ Signal raised by the system ○ Signal observed by the system ● Example ○ Battery is low ○ Virtual machine is about to perform a scheduled reboot Occurrence

Slide 7

Slide 7 text

Event ● A data record expressing an occurrence and its context ● Routed from an event producer to interested event consumers Event Occurrence

Slide 8

Slide 8 text

Event > Event Data ● Represent the domain-specific information about the Occurrence ● The payload will be encapsulated within data attribute ● Encoded into a media format specified by the datacontenttype context attribute Event Data Occurrence { "datacontenttype": "text/xml", "data" : "" }

Slide 9

Slide 9 text

Event > Context ● Provide contextual information about the Occurrence ● Context metadata will be encapsulated in the Context Attributes ● Context Attributes ○ Strongly typed: Boolean, Integer, String, Binary, URI, URI-reference, Timestamp ○ Required / Optional / Extension attributes Event Data Occurrence Context

Slide 10

Slide 10 text

Event > Context > Required Attributes ● id ○ Identifies the event. ○ Must be unique within the scope of the producer (ensure source + id is unique) ● source ○ Identifies the context in which an event happened. ● specversion ○ The version of the CloudEvents specification. ● type ○ Describe the type of event related to the originating occurrence Event Data Occurrence Context

Slide 11

Slide 11 text

Event > Context > Other Attributes ● Optional Attributes ○ datacontenttype, dataschema, subject, time ● Extension Context Attributes ○ A CloudEvent can include any number of additional context attributes with distinct names Event Data Occurrence Context

Slide 12

Slide 12 text

Message ● Events are transported from a source to a destination via messages ● Encoded to ○ Protobuf ○ JSON ○ Avro ○ ..etc. Message Event Context Data Occurrence { "specversion" : "1.0", "type" : "com.github.pull.create", "source" : "https://github.com/cloudevents/spec/pull", "subject" : "123", "id" : "A234-1234-1234", "time" : "2018-04-05T17:31:00Z", "comexampleextension1" : "value", "comexampleothervalue" : 5, "datacontenttype" : "text/xml", "data" : "" } { "specversion" : "1.0", "type" : "com.github.pull.create", "source" : "https://github.com/cloudevents/spec/pull", "subject" : "123", "id" : "A234-1234-1234", "time" : "2018-04-05T17:31:00Z", "comexampleextension1" : "value", "comexampleothervalue" : 5, "datacontenttype" : "application/octet-stream", "data" : "T3BlbkluZnJhRGF5cyBLb3JlYSAyMDE4" } { "specversion" : "1.0", "type" : "com.github.pull.create", "source" : "https://github.com/cloudevents/spec/pull", "subject" : "123", "id" : "A234-1234-1234", "time" : "2018-04-05T17:31:00Z", "comexampleextension1" : "value", "comexampleothervalue" : 5, "datacontenttype" : "application/json", "data" : {"appinfoA": "abc"} } Context Data

Slide 13

Slide 13 text

Protocol ● Messages can be delivered through various protocol ● Industry standard protocols ○ HTTP, AMQP, MQTT, SMTP ● Open-source protocols ○ Kafka, NATS ● Platform/Vendor specific protocols ○ AWS Kinesis, Azure Event Grid Protocol Message Event Context Data Occurrence

Slide 14

Slide 14 text

Routing ● Producer: create the data structure describing the CloudEvent ● Intermediary: receive a message and forward it to the next receiver ● Consumer: receive the event and acts upon it Producer Intermediary Intermediary Consumer Consumer

Slide 15

Slide 15 text

CloudEvent SDKs ● CloudEvents provides SDKs for ○ Go ○ Javascript ○ Java ○ C# ○ Ruby ○ Python

Slide 16

Slide 16 text

CloudEvent SDKs example Go Python

Slide 17

Slide 17 text

CloudEvent Integrations

Slide 18

Slide 18 text

CloudEvent Integrations > Knative ● Knative is a set of open source components for Kubernetes ○ Serving: run stateless workloads, such as microservices ○ Eventing: support event subscription, delivery, and handling Some Event Producer Knative Eventing Knative Serving deliver events trigger some k8s workloads event occurrence

Slide 19

Slide 19 text

Summary ● CloudEvents is a specification for describing event data in a common way ● CloudEvents can deliver any event with various content type / transport ● CloudEvents supports SDKs for mainstream languages ● Some major parties are already integrating their eventing with CloudEvents

Slide 20

Slide 20 text

References ● https://en.wikipedia.org/wiki/Event_(computing) ● https://cloudevents.io/ ● https://github.com/cloudevents/spec/ ● https://www.slideshare.net/openstack_kr/openinfra-days-korea-2018-track-4- cloudevents

Slide 21

Slide 21 text

Thank you