GSoC 2022: Support Knative as Eventing Infra
Mentee: Pengcheng Ma, pchengma@link.cuhk.edu.hk
Mentor: Weiming Xue, PPMC of Apache EventMesh, mikexue@apache.org
Project Website: https://eventmesh.apache.org/
Project GitHub: https://github.com/apache/incubator-eventmesh
About
Knative Eventing provides tools for routing events from event producers to sinks, enabling developers to use an event-driven architecture with their applications. Apache EventMesh supports the CloudEvents specification, thus it could be integrated with Knative as an event broker.
Background
Apache EventMesh
Apache EventMesh is a dynamic cloud-native eventing infrastructure used to decouple the application and backend middleware layer, which supports a wide range of use cases that encompass complex multi-cloud, widely distributed topologies using diverse technology stacks.
Knative
Knative is a platform-agnostic solution for running serverless deployments. Knative Eventing, one of Knative components, is a collection of APIs that enable developers to use an event-driven architecture with their applications. Developers can use these APIs to create components that route events from producers to consumers.
Contribution
Task
- ✅ Learn the details of the CloudEvents specification
- ✅ Learn the basics of Knative Eventing and its communication protocol
- ✅ Implement the EventMesh Knative-Connector module to deliver events to Knative
Note: All planned tasks for GSoC’ 22 are done.
Deliverable
- ✅ Source Code
- ✅ Integration Test
- ✅ Documentation
Note: All deliverables for GSoC’ 22 are reviewed and approved by the community.
Issue
- Issue #790 (Assigned)
- Issue #1187 (Status: Closed as Completed)
- Issue #1213 (Status: Closed as Completed)
Pull Request
- Pull Request #1027 (Status: Merged)
- Pull Request #1185 (Status: Merged)
- Pull Request #1214 (Status: Merged)
- Pull Request #1225 (Status: Merged)
Design and Implementation
Architecture
The architecture of EventMesh-Connector-Knative is depicted as Figure 1. To connect EventMesh to Knative, we need to consider two event routing directions.
The first direction is from EventMesh to Knative (black line). User sends an request to EventMesh, which defines an event message header and asks EventMesh to publish (EventMesh-Connector-Knative/KnativeProducer) this event message to the Knative broker. Knative sink subscribes event message, which can be handled by Knative Eventing component.
The second direction is from Knative to EventMesh (red line). Knative source sends an event message to the Knative broker. EventMesh subscribes (EventMesh-Connector-Knative/KnativeConsumer) the event message accoding to given topic from the Knative broker. After that, the event message can be consumed by user.
Demo
Preparation
We use cloudevents-player
as Knative source and sink. We use an InMemoryChannel-backed Knative broker. We clone the Apache EvnetMesh GitHub repository. All these installation steps are done on a cloud server.
Demo-01: Publish an Event Message from Knative and Subscribe from EventMesh
Step 1: Start an EventMesh Server
Step 2: Publish an Event Message from Knative
Step 3: Subscribe from EventMesh
The event message with data
field as Hello CloudEvents!
will be printed on the console of EventMesh server.
Demo-02: Publish an Event Message from EventMesh and Subscribe from Knative
Step 1: Publish an Event Message from EventMesh
Step 2: Subscribe from Knative
The event message with data
field as Hello Knative from EventMesh!
will be printed on the console.
Conclusion
In this project, we design and implement an EventMesh-Connector-Knative module that connects Apache EventMesh to Knative. In this way, Apache EventMesh obtains the ability of Knative and developers can directly use Apache EventMesh to enable Knative functions.
Future Work
In the future, we plan to add Apache EventMesh as a thrid-party broker to the Knative community. I will also keep contributing to the Apache EventMesh community and try to make EventMesh-Connector-Knative module meet the requirements in the production environment.
Acknowledgement
This project is supported by the Google Summer of Code program and The Apache Software Foundation. Firstly, I want to thank my mentor, Mr. Weiming Xue (Mike), who guides me through the whole project, especially but not limited to design, implementation, code review, and community bonding. Secondly, I want to thank Mr. Guangsheng Chen (Eason), PPMC of Apache EventMesh, who provides super helpful suggestions for the project review. Last but not least, I want to thank the Apache EventMesh community contributors for their inspirable issue and pull request activities.