Slide 1

Slide 1 text

Mauricio Salatino & Thomas Vitale Devoxx UK May 11th, 2022 Knative and Spring Bringing back the func @salaboy @vitalethomas

Slide 2

Slide 2 text

Mauricio Salatino VMware - Knative OSS * a.k.a @Salaboy * Sta ff Engineer - Knative Eventing tech lead for VMware * Knative OSS core contributor * Passionate about Functions, Platforms, Open Source and Kubernetes salaboy.com

Slide 3

Slide 3 text

Systematic * Software Architect at Systematic, Denmark. * Author of “Cloud Native Spring in Action” (Manning). * Spring Security and Spring Cloud contributor. Thomas Vitale thomasvitale.com @vitalethomas

Slide 4

Slide 4 text

Quiz Game thomasvitale.com @vitalethomas @salaboy @vitalethomas Building applications using functions

Slide 5

Slide 5 text

Serverless @salaboy @vitalethomas

Slide 6

Slide 6 text

Serverless Architectures Developers focus on code Focus on business logic @salaboy @vitalethomas Developer Platform Infrastructure Provisioning Workload Management Dynamic Scaling

Slide 7

Slide 7 text

Knative Serving Serverless Containers on Kubernetes Developer-friendly abstractions From code to URL Autoscaling Scaling to zero Progressive Rollouts Request-driven Event-driven @salaboy @vitalethomas Cloud agnostic

Slide 8

Slide 8 text

Demo thomasvitale.com @vitalethomas @salaboy @vitalethomas Knative Serving - From code to URL

Slide 9

Slide 9 text

Functions @salaboy @vitalethomas

Slide 10

Slide 10 text

Functions Functional programming model Triggered by requests or events Stateless Smaller scope Cold start Cost optimization @salaboy @vitalethomas

Slide 11

Slide 11 text

Functions Patterns Synchronous Interactions Function HTTP Fire and Forget

Slide 12

Slide 12 text

Functions Patterns Synchronous Interactions Function HTTP Request / Response

Slide 13

Slide 13 text

Functions Patterns Synchronous Interactions Function HTTP Request / Response (Sync) State

Slide 14

Slide 14 text

Functions Patterns Synchronous Interactions Function HTTP Request / Response (Scaling) State Function Function Load Balancer

Slide 15

Slide 15 text

Functions Patterns Synchronous Interactions HTTP Request / Response (Scaling) State Load Balancer Not running useless containers

Slide 16

Slide 16 text

Functions Patterns Asynchronous Interactions Async Processing Function HTTP Doing something that takes a long time …………………………………………… ………………………………………………… …………………………………………………… ……………………………………………… ……………………………………… Results

Slide 17

Slide 17 text

Functions Patterns Asynchronous Interactions Event Based Function CloudEvent CloudEvent

Slide 18

Slide 18 text

Functions Patterns Asynchronous Interactions Chaining Functions Function CloudEvent Event Router Function Function

Slide 19

Slide 19 text

Functions Patterns Mix and match Function Request / Reply + Events CloudEvent HTTP Event Router

Slide 20

Slide 20 text

Knative Functions Working with the func CLI @salaboy @vitalethomas func create ‣Initialize project ‣Polyglot support ‣Java, Go, Python 1 func build ‣Build and containerize ‣Use Buildpacks ‣No Docker fi le 2 func deploy ‣Run on Kubernetes ‣Knative deployment ‣No YAML 3

Slide 21

Slide 21 text

Demo thomasvitale.com @vitalethomas @salaboy @vitalethomas Knative Functions - From code to URL (GO)

Slide 22

Slide 22 text

Func - extras In active development, join the community! * External template repos * func run * On-cluster build, no Docker locally * 1.0 GA is on the roadmap

Slide 23

Slide 23 text

Functions with Spring @salaboy @vitalethomas

Slide 24

Slide 24 text

Spring Native Native executables with GraalVM Slower Heavier Build Instant Startup Reduced Memory Consumption Instant Peak Performance Fewer Runtime Optimizations @salaboy @vitalethomas

Slide 25

Slide 25 text

Functional Programming Paradigm Java 8 Functional Interfaces Supplier Function Consumer @salaboy @vitalethomas

Slide 26

Slide 26 text

Spring Cloud Function Business logic as functions Transparent Type Conversion Function Arity Function Composition Reactive Support JAR Functions @salaboy @vitalethomas

Slide 27

Slide 27 text

Demo thomasvitale.com @vitalethomas @salaboy @vitalethomas Knative Functions - From code to URL (Spring)

Slide 28

Slide 28 text

Function Composition Data processing via functions uppercase() sentence() Data processing “I play the PIANO” “piano” “PIANO”

Slide 29

Slide 29 text

Spring Cloud Function Deployment and integrations Knative CloudEvents RSocket Azure Functions Google Cloud Functions AWS Lambda @salaboy @vitalethomas

Slide 30

Slide 30 text

Game - Architecture @salaboy @vitalethomas

Slide 31

Slide 31 text

Kubernetes Cluster Function-based Game architecture Game architecture React Application Game FrontEnd Start Game Level X … Get LeaderB Redis (State) HTTP SYNC Level 1 …

Slide 32

Slide 32 text

Takeaways and challenges Synchronous functions Functions scale up and down based on demand An Orchestrator is needed Synchronising state is hard Make sure that the data store is not a bottleneck Latency can become an issue @salaboy @vitalethomas

Slide 33

Slide 33 text

Events @salaboy @vitalethomas

Slide 34

Slide 34 text

Knative Eventing Event routing and triggers Developer-friendly abstractions Event-driven architectures Event routing Polyglot support with CloudEvents Pluggable @salaboy @vitalethomas Cloud agnostic

Slide 35

Slide 35 text

CloudEvents Interoperability and standardization Metadata Data Id Source Type Payload JSON AMQP Kafka MQTT

Slide 36

Slide 36 text

Game - Events @salaboy @vitalethomas

Slide 37

Slide 37 text

Routing Events with Knative Eventing CloudEvents & RSocket Kubernetes Cluster React Application Game FrontEnd Level X … Redis HTTP SYNC Broker Trigger Score CloudEvent RSocket GameScore CloudEvent Trigger Another Function

Slide 38

Slide 38 text

Takeaways and challenges Eventing An event-based approach enable more reactive scenarios Knative Eventing abstracts the message broker implementations CloudEvents provide a standard structure for sharing data Monitoring is required to understand how data is fl owing We need to deal with eventual consistency in our applications @salaboy @vitalethomas

Slide 39

Slide 39 text

Discount codes Manning • 35% discount code, valid for all products in all format • ctwdevoxxuk22 • manning.com

Slide 40

Slide 40 text

Resources Source code • Learn more about the game: • https://github.com/salaboy/from-monolith-to-k8s/tree/main/game • Deploy the game on Kubernetes: • https://github.com/ThomasVitale/eventing-game • Spring Cloud Function samples: • https://github.com/ThomasVitale/devoxxuk-2022-knative-spring-func

Slide 41

Slide 41 text

Mauricio Salatino & Thomas Vitale Devoxx UK May 11th, 2022 Knative and Spring Bringing back the func @salaboy @vitalethomas