Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Developing Serverless Applications on Kubernetes with Knative


Published on

Serverless computing has become a hot topic in developer communities. The use of ephemeral containers eliminates the need for always-on infrastructure.

But the real payoff for serverless is greater code simplicity and developer efficiency. Sounds great! Except the open-source serverless framework space is crowded and complex. Each unique offering approaches functions differently, with varying methods for triggering, scaling, and event formatting. How is that efficient?

One thing that most everybody can agree on is to build on top of Kubernetes. With that as the only common ground though, there is still too much fragmentation for developers to wade through when deciding on the right open source serverless solution.

That's where Knative comes in. An open-source project from Google, Pivotal, and other industry leaders, Knative provides a set of common tooling on top of Kubernetes to help developers build serverless applications.

It extends Kubernetes by combining Istio with Custom Resource Definitions to enable a higher-level of abstraction for developers. This brings support for source-to-container builds, autoscaling, routing, and event sourcing. Join this session with Brian McClain and Bryan Friedman to see a complete working demo of Knative and learn:

● What are the components of Knative and how do they work together
● What are the different ways to deploy serverless applications and functions on Knative
● How and when to use Knative’s build features, such as Buildpacks
● What is Knative’s eventing model and how are event sources used to trigger functions

Bryan Friedman, Director of Product Marketing, Pivotal and Brian McClain, Principal Product Marketing Manager, Pivotal

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Developing Serverless Applications on Kubernetes with Knative

  1. 1. © Copyright 2019 Pivotal Software, Inc. All rights Reserved. Brian McClain Bryan Friedman Developing Serverless Applications on Kubernetes with Knative Webinar
  2. 2. Cover w/ Image Agenda ■ What is Knative? ■ Knative Components with Examples ■ Project riff ■ Demo Application ■ Q+A
  3. 3. Knative: A platform for developers to build and run serverless applications atop Kubernetes
  4. 4. Eventing How your code is triggered by events ● Apps and functions consume and publish event streams ● Multiple event sources available ● Encourages asynchronous, loosely coupled architecture Build How your code is built and packaged as a container ● Pluggable model to build containers from source code ● Build in-cloud or on-cluster ● Push image to registry ● Templates available (e.g. Buildpacks) Serving How your code receives requests and scales with them ● Request-driven compute runtime ● Scale-to-zero / scale out per load ● Deploy from container registry ● Multiple revisions of same app ● Route traffic across revisions DETAILS DETAILS DETAILS Knative Components
  5. 5. Serving Flexible scaling and routing to your application. ● Automatically deploy containers and configure routing ● Automatically scale up and down, including scale-to-zero ● Point-in-time snapshots of deployments allows multiple versions of applications at once ● Easy rollbacks, blue-green deployments, partial load testing, etc.
  6. 6. {app-name}.{namespace}.{custom-domain} Serving - Deployment n-1 n
  7. 7. Serving - Deployment apiVersion: kind: Service metadata: name: knative-helloworld namespace: default spec: runLatest: configuration: revisionTemplate: spec: container: image:
  8. 8. n+1 Serving - Request Handling n-1 n HTTP
  9. 9. n+1 Serving - Scaling Up n-1 n n n HTTP
  10. 10. n+1 Serving - Scaling Down n-1 n
  11. 11. Serving - Scaling Down
  12. 12. n+1 Serving - Scaling Down n-1 n
  13. 13. Serving - Percentage-Based Routing n-1 n HTTP 100% name: v1
  14. 14. n+1 Serving - Percentage-Based Routing n-1 n HTTP 100% 0% name: v1 name: v2
  15. 15. n+1 Serving - Percentage-Based Routing n-1 n HTTP 50% 50% name: v2 name: v1
  16. 16. n+1 Serving - Percentage-Based Routing n-1 n HTTP 0% 100% name: v2 name: v1
  17. 17. Serving - Percentage-Based Routing apiVersion: kind: Route metadata: name: knative-routing-demo namespace: default spec: traffic: - revisionName: knative-routing-demo-00001 name: v1 percent: 50 - revisionName: knative-routing-demo-00002 name: v2 percent: 50
  18. 18. Build Build and package code on-cluster. ● Builds are ran completely within Kubernetes ● Code is pulled from git at build time ● Packaged as container images and pushed to a registry of your choice ● Build Templates are prepackaged descriptions of different ways to build code
  19. 19. Kaniko. Build container images inside of containers Jib. Build container images optimized for Java applications Buildpacks. Build container images using Cloud Foundry’s Buildpack build system And more! The list of Build Templates is constantly growing Build Templates
  20. 20. Build Code Container Image
  21. 21. Build spec: runLatest: configuration: build: serviceAccountName: build-bot source: git: url: revision: master template: name: kaniko arguments: - name: IMAGE value:
  22. 22. Eventing Robust eventing support that abstracts away the messaging layer. ● Easy for developers to consume events - No messaging-specific code ● Messaging layer is abstracted from the developer and pluggable for the operator ● Abstract persistent Channels allows events to be delivered to multiple functions ● Pluggable, Customizable Event Sources
  23. 23. Example Event Sources Cron Job. Produce events on a specified Cron schedule GitHub. Events happening in a GitHub repository/organization (commit, new pull request, etc) trigger your function Google Cloud Storage. Invokes your function when files are uploaded or changed in a specified bucket AWS SQS. Messages on SQS are forwarded to your function
  24. 24. Custom Event Sources Event Sources are pluggable and not tightly bundled to Knative ● Community-developed event sources are installed by applying a YAML file ● ContainerSource makes it easy to build your own event source ○ Package your event emitter as a container, Knative gives a URI to POST to
  25. 25. Eventing - Direct Delivery Event Source
  26. 26. Eventing - Fan-Out Delivery Event Source Channel Subscription Subscription
  27. 27. Eventing - Channel apiVersion: kind: Channel metadata: name: knative-eventing-demo-channel spec: provisioner: apiVersion: kind: ClusterChannelProvisioner name: in-memory-channel
  28. 28. Eventing - Source apiVersion: kind: KubernetesEventSource metadata: name: k8sevents spec: namespace: default serviceAccountName: events-sa sink: apiVersion: kind: Channel name: knative-eventing-demo-channel
  29. 29. Eventing - Subscription apiVersion: kind: Subscription metadata: name: knative-eventing-demo-subscription spec: channel: apiVersion: kind: Channel name: knative-eventing-demo-channel subscriber: ref: apiVersion: kind: Service name: knative-eventing-demo-app
  30. 30. Custom Event Sources - Container Source apiVersion: kind: ContainerSource metadata: labels: "1.0" name: my-event-source spec: image: sink: apiVersion: kind: Service name: my-event-source
  31. 31. Project riff
  32. 32. Evolution of Project riff
  33. 33. Project riff Makes Knative Better. Tools and extensions to make the Knative developer experience even better riff CLI. Make easy to quickly deploy functions to Knative and configure event channels. Removes the need to manage YAML. Invokers. Allows developers to focus on their functions, invokers will handle setting up the webserver and running your code
  34. 34. Project riff - Without Invokers const express = require("express"); const bodyParser = require('body-parser') const app = express(); app.use(bodyParser.text({type: "*/*"}));"/", function(req, res) { res.send("Hello, " + req.body + "!"); }); const port = process.env.PORT || 8080; app.listen(port, function() { console.log("Server started on port", port); });
  35. 35. Project riff - With Invokers module.exports = x => "Hello, " + x + "!";
  36. 36. Project riff - Deploying Functions
  37. 37. Pivotal's commercially supported, opinionated packaging of riff + Knative. Expected to run on PKS or Kubernetes anywhere. Alpha Release Now Available (by request) General Availability TBD
  38. 38. Demo
  39. 39. Demo Application - Earthquake Visualization
  40. 40. PSQL Geocoder Function Frontend USGS Event Source USGS Event Feed Demo Application - High-Level Visualization
  41. 41. Demo Application - Detailed Visualization Geocoder Function Code Frontend Code HTTP 1 2 3 4 Frontend Geocoder Function USGS Event Feed PSQL USGS Event Source
  42. 42. Available Now @BrianMMcClain @bryanfriedman
  43. 43. Join Us At CF Summit @BrianMMcClain @bryanfriedman
  44. 44. Questions? Q+A
  45. 45. Transforming How The World Builds Software © Copyright 2019 Pivotal Software, Inc. All rights Reserved.