Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Event-driven serverless architectures with Knat...

Mete Atamel
September 22, 2020

Event-driven serverless architectures with Knative and Cloud Run

When you combine the efficiency of containers, agility of serverless and flexibility of event-driven services, you end up with a more reusable, interoperable and scalable architecture with minimal management overhead.

In this talk, we’ll explore the open-source Knative Eventing and its managed version Cloud Run. We’ll explore what they provide for event-driven serverless containers and we’ll deep dive into some real-world reference architectures.

At the end of this session, you’ll have a solid understanding on how Knative and Cloud Run can power your event-driven apps.

Mete Atamel

September 22, 2020
Tweet

More Decks by Mete Atamel

Other Decks in Technology

Transcript

  1. Event-driven serverless architectures with Knative and Cloud Run Mete Atamel

    Developer Advocate at Google @meteatamel atamel.dev speakerdeck.com/meteatamel
  2. Operational Model Programming Model No Infra Management Managed Security Pay

    only for usage Service-based Event-driven Stateless Serverless
  3. Cloud Run Fully managed, deploy your workloads and don’t see

    the cluster. Cloud Run on Anthos Deploy into Anthos, run serverless side-by-side with your existing workloads. Knative Everywhere Use the same APIs and tooling anywhere you run Kubernetes with Knative. Serverless containers with Knative and Cloud Run
  4. Confidential & Proprietary What is Knative? Kubernetes based open source

    building blocks for serverless github.com/knative
  5. Confidential & Proprietary Knative Serving What is it? Rapid deployment

    of serverless containers Automatic (0-n) scaling Configuration and revision management Traffic splitting between revisions Pluggable Connect to your own logging and monitoring platform, or use the built-in system Auto-scaler can be tuned or swapped out for custom code
  6. Confidential & Proprietary Knative Serving Knative Service High level abstraction

    for the application Configuration Current/desired state of an application Code & configuration separated (a la 12-factor) Revision Point in time snapshots for your code and configuration Route Maps traffic to revisions
  7. Confidential & Proprietary Knative Eventing What is it? For loosely

    coupled, event-driven services A number of different delivery methods Scales from just few events to live streams Uses standard CloudEvents Delivery Methods Event source(s) Event type(s) Event consumer(s)
  8. Confidential & Proprietary Terminology of Knative Eventing CloudEvents → Format

    Event Source → Producer Broker → Event mesh in the namespace Trigger → Interest in messages from Broker & filter Service → Consumer Channel → Persistence layer Subscription → Interest in messages from channel
  9. Confidential & Proprietary CloudEvents - cloudevents.io { "specversion": "1.0", "type":

    "com.github.pull.create", "source": "https://github.com/cloudevents/spec/pull/123", "id": "A234-1234-1234", "time": "2019-04-08T17:31:00Z", "datacontenttype": "application/json", "data": "{ GitHub Payload... }" } FTP GitHub GCS Broker FTP Receive Adapter GitHub Receive Adapter GCS Receive Adapter CloudEvent
  10. Confidential & Proprietary Event Sources Name Description Apache Camel Allows

    to use Apache Camel components for pushing events into Knative Apache Kafka Brings Apache Kafka messages into Knative AWS SQS Brings AWS Simple Queue Service messages into Knative Cron Job Uses an in-memory timer to produce events on the specified Cron schedule. GCP PubSub Brings GCP PubSub messages into Knative GitHub Brings GitHub organization/repository events into Knative GitLab Brings GitLab repository events into Knative. Google Cloud Scheduler Google Cloud Scheduler events in Knative when jobs are triggered Google Cloud Storage Brings Google Cloud Storage bucket/object events into Knative Kubernetes Brings Kubernetes cluster/infrastructure events into Knative https://github.com/knative/docs/tree/master/docs/eventing/sources
  11. Broker Combines Channel, reply, and filter functionality into a single

    resource Typically injected one per namespace apiVersion: eventing.knative.dev/v1beta1 kind: Broker labels: eventing.knative.dev/namespaceInjected: "true" name: default namespace: default status: address: Url:http://default-broker.default.svc.cluster.local Broker
  12. Trigger Subscribes a Service to Broker Filtering apiVersion: eventing.knative.dev/v1beta1 kind:

    Trigger metadata: name: trigger-filter spec: filter: attributes: type: com.google.cloud.storage.object.finalize subscriber: ref: apiVersion: serving.knative.dev/v1 kind: Service name: filter Trigger
  13. Service Receives events Knative or Kubernetes Service Subscriber of a

    trigger or a sink of a source apiVersion: eventing.knative.dev/v1alpha1 kind: Trigger metadata: name: trigger-event-display spec: subscriber: ref: # apiVersion: v1 apiVersion: serving.knative.dev/v1 kind: Service name: event-display Knative Service
  14. Channel Persistence layer In-memory, PubSub, Kafka implementations Default channel apiVersion:

    messaging.knative.dev/v1beta1 kind: InMemoryChannel metadata: name: channel apiVersion: messaging.knative.dev/v1alpha1 kind: KafkaChannel metadata: name: my-kafka-channel spec: numPartitions: 1 replicationFactor: 1 Channel
  15. Subscription Subscribes Service to Channel Also defines the notion of

    event replies apiVersion: messaging.knative.dev/v1alpha1 kind: Subscription metadata: name: subscription1 spec: channel: apiVersion: messaging.knative.dev/v1alpha1 kind: InMemoryChannel name: channel subscriber: ref: apiVersion: serving.knative.dev/v1 kind: Service name: service1 Subscription
  16. Confidential & Proprietary Delivery Methods Simple Delivery Event Source →

    Service, 1:1 Complex Delivery with optional reply Event Source → Channels → Subscription → Services, 1:N Broker Trigger Delivery Event Source → Broker → Triggeer → Services, 1:N
  17. Confidential & Proprietary Knative GCP Project - github.com/google/knative-gcp Easy configuration

    and consumption of Google Cloud Platform events in Knative Ready to use event sources: 1. CloudPubSubSource 2. CloudStorageSource 3. CloudSchedulerSource 4. CloudAuditLogsSource 5. CloudBuildSource