Slide 1

Slide 1 text

Event-driven serverless architectures with Knative and Cloud Run Mete Atamel Developer Advocate at Google @meteatamel atamel.dev speakerdeck.com/meteatamel

Slide 2

Slide 2 text

Operational Model Programming Model No Infra Management Managed Security Pay only for usage Service-based Event-driven Stateless Serverless

Slide 3

Slide 3 text

Containers Any language Any library Ecosystem around containers .js .rb .go .py .sh … 0 1 0 1 0 0 1 1 1

Slide 4

Slide 4 text

Containers Flexibility Serverless Velocity

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

Confidential & Proprietary What is Knative? Kubernetes based open source building blocks for serverless github.com/knative

Slide 7

Slide 7 text

Knative Stack Serving Eventing Kubernetes Platform Products Components Cloud Run Cloud Run on Anthos Gateway Kourier Istio

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

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)

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

Confidential & Proprietary Simple Delivery

Slide 21

Slide 21 text

Confidential & Proprietary Complex Delivery

Slide 22

Slide 22 text

Confidential & Proprietary Complex Delivery with reply

Slide 23

Slide 23 text

Confidential & Proprietary Broker Trigger Delivery

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

Confidential & Proprietary BigQuery Processing Pipeline

Slide 26

Slide 26 text

@meteatamel speakerdeck.com/meteatamel github.com/meteatamel/knative-tutorial knative.dev github.com/meteatamel/cloudrun-tutorial cloud.google.com/run Thank you!