Knative: Building serverless platforms on top of Kubernetes Ahmet - - PowerPoint PPT Presentation

knative building serverless platforms on top of kubernetes
SMART_READER_LITE
LIVE PREVIEW

Knative: Building serverless platforms on top of Kubernetes Ahmet - - PowerPoint PPT Presentation

Knative: Building serverless platforms on top of Kubernetes Ahmet Alp Balkan @ahmetb Thanks to Mark Chmarny, Ryan Gregg, DeWitt Clinton and Bret McGowen for some of the slides used in this presentation. Talking about servers at a serverless


slide-1
SLIDE 1

Knative: Building serverless platforms on top of Kubernetes

Ahmet Alp Balkan

@ahmetb

Thanks to Mark Chmarny, Ryan Gregg, DeWitt Clinton and Bret McGowen for some of the slides used in this presentation.

slide-2
SLIDE 2

Talking about servers at a serverless conference

slide-3
SLIDE 3

Serverless Kubernetes

slide-4
SLIDE 4

I work on developer tools and experiences for Kubernetes. I'm passionate about microservices, infrastructure-as-code, and RPC frameworks. Past: worked at Microsoft Azure on Linux and Docker. Follow me at @ahmetb.

slide-5
SLIDE 5

Kubernetes

slide-6
SLIDE 6

Kubernetes is the de facto platform for running containers.

slide-7
SLIDE 7

*Sources: COCOMO Model, CNCF Certified Providers , k8s.devstats.cncf.io

400+ Years of effort* 5,000+ Contributors 40k+ GitHub stars

The incredible Kubernetes ecosystem

slide-8
SLIDE 8

How did this happen?

Kubernetes encourages cattle; not pets.

  • Individual machines don't matter.

○ Container isolates the app from the host.

  • Containers are ephemeral: they come and go.
slide-9
SLIDE 9

How did this happen?

Kubernetes has a declarative API.

  • Apply the desired configuration to your cluster.
  • Kubernetes will drive "current state" to the "desired state"

eventually.

slide-10
SLIDE 10

How did this happen?

Kubernetes keeps your applications running while you're asleep.

  • Container died?

○ Restart it.

  • Container unhealthy?

○ Reschedule to another node.

  • Container overloaded?

○ Add more replicas automatically.

slide-11
SLIDE 11

How did this happen?

Kubernetes API is extensible.

  • You can create custom API types.
  • You can write custom controllers

to actuate the custom objects.

apiVersion: my.api/v1 kind: MysqlCluster metadata: name: orders-db spec: masters: 3 replicas: 12 storage: innodb: {}

slide-12
SLIDE 12

Kubernetes is not easy

  • 1. It was never meant to be used by developers directly.
  • 2. Creating and operating Kubernetes clusters in production

is pretty much a full time job.

slide-13
SLIDE 13

Google Kubernetes Engine (GKE)

The zero ops cluster experience:

  • update your cluster to new versions of Kubernetes
  • scale the cluster up/down automatically
  • detect and replace broken nodes of the cluster
slide-14
SLIDE 14

It's not the correct end-developer experience. (This doesn't stop developers from using Kubernetes directly!) But it's a great platform for building a PaaS on top of.

Kubernetes isn't actually for developers

slide-15
SLIDE 15

Developers using Kubernetes

Have to do Write code Build docker image Upload image to registry Deploy service Expose to the internet Set up monitoring Set up autoscaling Want to do Write code

slide-16
SLIDE 16

Why do developers still use Kubernetes?

  • Some people want control over their infrastructure

(VMs, machines, OS images, networking, security, ...)

  • Not everyone is on cloud yet, or they want to avoid

vendor lock-in.

  • Kubernetes lets you effectively manage a large set of

{machines, deployments}.

slide-17
SLIDE 17

Serverless

slide-18
SLIDE 18

Serverless > Functions

slide-19
SLIDE 19

Compute

Storage Messaging Data processing Database Data warehouse AI

Serverless is more than snippets of code

slide-20
SLIDE 20

Cloud Dataflow Cloud Machine Learning Cloud Storage Cloud PubSub Cloud Functions App Engine BigQuery Cloud Datastore

Serverless is more than snippets of code

slide-21
SLIDE 21

No servers Idiomatic Event-driven Free of lock-in

Promise of serverless

slide-22
SLIDE 22

Developers

… just want to run their code. ... want to use their favorite languages and dependencies. … don't want to manage the infrastructure.

slide-23
SLIDE 23

The case for

Serverless on Kubernetes

slide-24
SLIDE 24

Developers want serverless

... just want to run their code. ... want to use their favorite languages and dependencies. ... don't want to manage the infrastructure.

Operators want Kubernetes

Kubernetes is great orchestrating microservices They love using GKE and not having to do operations for Kubernetes. Kubernetes is not the right abstraction for their developers.

slide-25
SLIDE 25

Why would you want serverless on Kubernetes?

Ask the developers of >13 open source Kubernetes-based FaaS/serverless projects. :)

slide-26
SLIDE 26

Why would you want serverless on Kubernetes?

1. Your company doesn't use cloud (or wants vendor lock-in) 2. Need control over the infrastructure, machines, host OS, ... 3. Kubernetes offers good abstractions to build upon.

slide-27
SLIDE 27

No servers Idiomatic Event-driven Free of lock-in

How to get this on Kubernetes?

slide-28
SLIDE 28

“The majority of people managing infrastructure just want PaaS. There's only one requirement:

slide-29
SLIDE 29

“The majority of people managing infrastructure just want PaaS. There's only one requirement: It has to be built by them.”

  • Kelsey Hightower
slide-30
SLIDE 30

Serverless stack

Invokers Event Binding

Kubernetes Platform Products Primitives

Autoscaling Observability Build Routing

...

DX Event Sources Runtimes

...

Effort scope

slide-31
SLIDE 31

Serverless stack

Invokers Event Binding

Kubernetes Platform Products Primitives

Autoscaling Observability Build Routing

...

DX Event Sources Runtimes

...

Duplication

  • f efforts

Decreased portability Opportunity lost

slide-32
SLIDE 32

What if I told you, we can still fulfill the serverless promises on servers (but you don't have to manage them)?

slide-33
SLIDE 33

Knative

slide-34
SLIDE 34

Building blocks for creating serverless experiences

  • n top of Kubernetes.

github.com/knative

Hello Knative

slide-35
SLIDE 35

Knative collaborators

slide-36
SLIDE 36

The Knative Stack

Kubernetes Platform

slide-37
SLIDE 37

The Knative Stack

Knative Build Serving Events Kubernetes Platform Primitives

slide-38
SLIDE 38

Knative Build Serving Events Kubernetes Platform Products

Serverless Containers on GCF GKE Serverless Add-on SAP Kyma Pivotal Function Service IBM Cloud Functions Red Hat Cloud Functions

Primitives

riff OpenFaaS Jazz

slide-39
SLIDE 39

What Knative is

  • An open source project
  • Set of building blocks to construct your own FaaS/PaaS

○ abstracts common tasks through custom Kubernetes API objects

  • An abstraction on top of Kubernetes.

○ It's still Kubernetes: Runs containers at the end of the day.

slide-40
SLIDE 40

What Knative is not

  • It's not a Google product.
  • It's not a FaaS.
slide-41
SLIDE 41

What can you do with Knative?

  • [Developers] Use it directly to deploy stuff (not easy, but works fine)
  • [Operators] Put a level of abstraction between your devs and

Kubernetes.

  • [Platform Architects] Use it to build your own serverless platform.

○ e.g. DIY Heroku or GCF/Lambda.

slide-42
SLIDE 42

Infrastructure Primitives

Knative Kubernetes Off-the-shelf FaaS

(riff, OpenFaaS, Apache Whisk…)

Developer Experience

Your in-house FaaS platform Developers

slide-43
SLIDE 43

DIY FaaS on Kubernetes (oversimplified)

  • Something to wake up your workload (activation) on request.
  • Something to scale up, and back to zero.
  • Something to turn your app/function into a container
  • Something to collect metrics and export telemetry from the app.
  • Handling of revisions of the code+config (+ability to rollback)
  • A way to offer traffic splitting (gradual rollout)
  • An eventing system with configurable sources/flows/subscribers
slide-44
SLIDE 44

Knative building blocks

Build Serving Events

slide-45
SLIDE 45

Knative components

  • Serving: Revisions, Traffic Splitting, Autoscaling
  • Build: On-cluster builds and transformations
  • Eventing: Declarative way to bind event sources to services
slide-46
SLIDE 46

Knative Serving

Benefits

  • Seamlessly scale up and down
  • Built-in traffic splitting between

revisions

  • Integrates networking and

service mesh automatically

  • Easy to reason about object

model

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-47
SLIDE 47

Knative Serving

Primitives with clear separation of concerns: 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 a revisions Supports fractional, named routing

slide-48
SLIDE 48

Knative Build

Lets you go from source code to container images.

  • Build pipelines can consist of multiple steps
  • Each build step is a container image.
  • Builds run inside the containers on the cluster.

Makes it possible to do GitOps and go from "git push" to a running URL.

slide-49
SLIDE 49

source: git: url: git://github.com/example/foo.git steps:

  • name: compile

image: gcc args: ["gcc", "-o", "a.out"]

  • name: build

image: docker-cli args: ["docker", "build", "--tag", "my-image", "."]

  • [...]

Knative Build: Source-to-container image

slide-50
SLIDE 50

Knative Build: Function-to-container

Step 1: function to app (add an invoker for your function) Step 2: app to a container (add a buildpack environment) Step 3: push container to a registry

slide-51
SLIDE 51

Knative Build: Benefits

  • Flexible: Control over how your source is turned into artifact (container image).
  • Builds happen on the cluster.

○ No need for Docker locally ○ Cached Docker builds ○ Faster image pushes ○ No cross-compiling toil

slide-52
SLIDE 52

Knative on-cluster build

Benefits

  • No cross-compiling toil
  • No need for Docker locally
  • Cloud caching, faster image push
  • Tooling ecosystem for Enterprise

Policy to audit Builds

Loosely coupled

  • Use it to get started, and

graduate to decoupled CI

  • Keep your existing CI/CD to

get started, and graduate to audited Builds

slide-53
SLIDE 53

Knative Eventing

(Work in progress, subject to change.) Eventing constructs :

  • Event Sources (producer)
  • Event Types (different events)
  • Event Actions (any route)
  • Event Feeds (configuration)

Event type Flow Event source Event type Event type Event consumer(s)

slide-54
SLIDE 54

Knative Eventing

Benefits

  • Declaratively bind between event

produces and your services

  • Custom event pipelines to connect

with your own existing systems

Event type Flow Event source Event type Event type Event consumer(s)

slide-55
SLIDE 55

Knative development principles Organic

03

Extensible

02

Idiomatic

01

  • Feel native on Kubernetes
  • Meet the developer
  • Loose coupling at the top
  • Pluggable at the bottom
  • Codify the commonalities
  • Build a stable platform
slide-56
SLIDE 56

Demo

slide-57
SLIDE 57

Thanks!

github.com/knative cloud.google.com/knative g.co/serverlessaddon (alpha sign-up)