Red Hat OpenShift Cloud Functions

Bringing serverless capabilities to Red Hat OpenShift

Docs and APIs

Documents Links Section

Knative provides the building blocks for modern container-based serverless applications, providing an opinionated workflow for developers that leverages best practices shared by a variety of other Kubernetes-based frameworks.  It accomplishes that through 3 well-defined modules: build, serving and events, which combined can deliver serverless capabilities, like auto-scale, high-availability, event-based computing, among others.

Serving

The Serving component revolves around the concept of a Service (for clarity, it's called KService throughout, because that term is vastly overloaded in the Kubernetes space). A KService is a higher level construct that describes how an application is built and then how it's deployed in Knative.

Eventing

The previous steps showed you how to invoke a KService from an HTTP request, in that case, submitted via curl. Knative Eventing is all about how you can invoke those applications in response to other events such as those received from message brokers or external applications. In this part of the demo, we are going to show how you can receive Kubernetes platform events and route those to a Knative Serving application.

Knative Eventing is built on top of three primitives:

  • Event Sources
  • Channels
  • Subscriptions

Event Sources are the components that receive the external events and forward them onto Sinks which can be a Channel. Out of the box we have Channels that are backed by Apache Kafka and simple in-memory channel. Subscriptions are used to connect Knative Serving application to a Channel so that it can respond to the events that the channel emits.

Build

The Build component in Knative is not so much a utility to build images themselves. It rather provides primitives, to be able to string together the tools you want to do your image build. In a sense, it's an abstraction layer above all the tools out there to build an image. In our case, the most prominent example is OpenShift's own build capability, so this will show you, how we can implement a Knative Build by the means of an OpenShift Build.

Knative provides a mechanism called BuildTemplates, where you define a blueprint for a build, which contains the arguments that that build might need to do its job of building the image in the end.