Kahibaro
Discord Login Register

19.3 Serverless and event-driven workloads

Key Concepts: Serverless and Event-Driven

Serverless and event-driven approaches focus on reacting to events with small, loosely-coupled units of compute rather than long-running services you manage directly.

On OpenShift, this typically means:

In the Kubernetes/OpenShift ecosystem, this space is largely represented by Knative and tools built on top of it.

Types of Serverless Models on OpenShift

There are several patterns relevant for OpenShift:

  1. Request-driven serverless (Knative Serving):
    • HTTP/HTTPS-triggered workloads.
    • Scale based on inbound requests; can scale to zero.
    • Suitable for APIs, webhooks, microservices with spiky or unpredictable traffic.
  2. Event-driven serverless (Knative Eventing and friends):
    • Functions/services triggered by arbitrary events: messages, timers, storage events, etc.
    • Uses a pub/sub model and CloudEvents for interoperability.
    • Suitable for asynchronous processing, pipelines, data ingestion, and automation.
  3. Function-as-a-Service (FaaS) abstractions on top of Knative:
    • Higher-level “functions” frameworks (e.g., OpenShift Serverless Functions, KNative functions frameworks).
    • Developers focus on a single function or small handler; build and deployment are automated.

These models can coexist in a single cluster and interoperate with traditional long-running deployments.

OpenShift Serverless: Core Building Blocks

OpenShift provides a commercial distribution of Knative under the umbrella of OpenShift Serverless. It typically consists of:

You interact with these components via:

Knative Serving: Serverless Services on OpenShift

Knative Serving provides:

When to Use Knative Serving vs Traditional Deployments

Use Knative Serving when:

Prefer standard Deployments/DeploymentConfigs when:

Event-Driven Architectures with Knative Eventing

Knative Eventing focuses on producing, routing, transforming, and consuming events in a decoupled way.

Key primitives:

Typical Event-Driven Patterns on OpenShift

Some common patterns using Knative Eventing:

  1. Webhook Fan-Out:
    • A single external webhook (e.g., Git, payment system) sends events to a Broker.
    • Multiple Triggers deliver different events to different services:
      • Build pipeline starter
      • Notification service
      • Audit logger
  2. Async Processing Queue:
    • A front-end API (possibly Knative Serving) immediately returns to the user.
    • It emits an event to a Channel or Broker.
    • Back-end worker services consume events and perform heavy processing.
  3. Event-Based Workflows:
    • Events from multiple systems (storage, message queues, databases) are combined.
    • Steps of business logic are implemented as small serverless services.
    • Each step emits a new event consumed by the next step.
  4. Policy/Compliance Hooks:
    • Cluster events (e.g., image scanned, policy violation) are fed into a Broker.
    • Specific Triggers direct relevant events to policy engines, notifiers, or auditors.

Serverless on OpenShift: Tooling and Developer Experience

OpenShift enhances the raw Knative experience with:

This is designed to reduce friction compared to managing raw Kubernetes or hand-crafted CI/CD logic for similar workloads.

Design Considerations and Trade-Offs

When deciding whether to use serverless/event-driven approaches on OpenShift, consider:

Performance and Cold Starts

Resource Economics

Observability and Debugging

Event-driven systems can be more complex to debug because:

Effective practices:

Reliability and Ordering

Design workflows to:

Security

Serverless components must adhere to cluster security controls:

Serverless and Event-Driven in Future OpenShift Ecosystem

Serverless/event-driven architectures intersect with several future-looking areas in the OpenShift ecosystem:

Practical Usage Scenarios

On OpenShift, expect to encounter serverless and event-driven workloads in scenarios such as:

Understanding these patterns prepares you to:

Views: 50

Comments

Please login to add a comment.

Don't have an account? Register now!