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

Knative and Kubernetes: bringing serverless to ...

Avatar for TechMasters TechMasters
September 28, 2018

Knative and Kubernetes: bringing serverless to more developers

By Bret McGowen - Google

Presented at Functions 2018 / ServerlessDays Toronto

https://functions.events/2018/toronto/bret-mcgowen/

Avatar for TechMasters

TechMasters

September 28, 2018
Tweet

More Decks by TechMasters

Other Decks in Programming

Transcript

  1. @BretMcG Serverless model(s) Operational model Fully managed security Pay only

    for usage No servers Event-driven Open Service-based Programming model
  2. @BretMcG Keep the serverless programming model, however your infrastructure is

    managed. Operational model Fully managed security Pay only for usage No servers Event-driven Open Service-based Programming model
  3. @BretMcG Hosted FaaS/compute Easiest dev experience Code focused Limited runtime

    options Serverless anywhere Knative / GKE serverless addon On prem or multi-cloud Code or containers Custom hardware (GPU, TPU, IoT, etc) Offline You manage infra Serverless operational spectrum Managed by your cloud Container orchestration (k8s) Not serverless for programming or ops Container focused You manage infra Managed by your team Serverless containers Custom languages & runtimes Infra still cloud-managed
  4. @BretMcG Hosted FaaS/compute Easiest dev experience Code focused Limited runtime

    options Hosted FaaS/compute Managed by your cloud Container orchestration (k8s) Not serverless for programming or ops Container focused You manage infra Managed by your team Serverless anywhere Knative / GKE serverless addon On prem or multi-cloud Code or containers Custom hardware (GPU, TPU, IoT, etc) Offline You manage infra Serverless containers Custom languages & runtimes Infra still cloud-managed
  5. @BretMcG Serverless Compute on Cloud Platform App Engine Standard Highly

    scalable, serverless web applications. Deploy and scale Applications that react to Requests Cloud Functions Event-driven serverless compute platform. Deploy and scale Functions that react to Events
  6. @BretMcG Back end code functions that automatically run in response

    to a trigger event Microservices Cloud "glue" Node.js 6, Node.js 8, Python 3.7, Go 1.11 (bit.ly/gcf-go-alpha) Pricing: per 100ms & based on allocated memory Cloud Functions
  7. @BretMcG Cloud Functions as cloud glue Access 20+ Google services

    from GCF Cloud Storage Cloud Pub/Sub HTTPS Firebase Cloud Scheduler
  8. @BretMcG Cloud Functions announcements Generally Available (with SLA!) Python 3.7,

    Node 8 Tokyo, Belgium, Iowa Environment Variables Cloud Scheduler New! Ubuntu 18.04 with many packages (ffmpeg, imagemagick, headless Chrome) Security Controls: VPC, IAM Scaling Controls Cloud SQL Direct Connect
  9. @BretMcG App Engine: 2nd generation runtimes New! Pay for what

    you use, scale to zero Open-source, idiomatic experience Use any module, extension, or framework New supported runtimes: ◦ Node.js 8 ◦ Python 3.7 ◦ PHP 7.2
  10. @BretMcG Serverless containers Managed by your cloud Container orchestration (k8s)

    Not serverless for programming or ops Container focused You manage infra Hosted FaaS/compute Easiest dev experience Code focused Limited runtime options Managed by your team Serverless anywhere Knative / GKE serverless addon On prem or multi-cloud Code or containers Custom hardware (GPU, TPU, IoT, etc) Offline You manage infra Serverless containers Custom languages & runtimes Infra still cloud-managed
  11. @BretMcG What are containers? app libs kernel libs app app

    kernel app libs libs kernel kernel libs app kernel libs app libs app libs app kernel libs app app app app Shared machines Virtual Machines Containers x x x x x x No isolation Common libs Highly coupled apps and OS Isolation No common libs Expensive and inefficient Hard to manage Isolation No common libs Less overhead Less dependency on host OS
  12. @BretMcG FROM python RUN apt-get update && apt-get install -y

    blender ENV APP_HOME /app COPY . $APP_HOME WORKDIR $APP_HOME RUN pip install Flask EXPOSE 8080 CMD ["python", "app.py"] Don't be afraid of this Image It’s a method of packaging an application executable and its dependencies (runtime, libraries, configuration) Runtime and running as a set of resource-isolated processes.
  13. @BretMcG Everything at Google runs in containers: Gmail, Web Search,

    Maps, ... MapReduce, batch, ... GFS, Colossus, ... Even GCE itself: VMs in containers We launch over 4 billion containers per week.
  14. @BretMcG Two serverless challenges today Dependencies Constrained runtimes, frameworks and

    packages Multi-Cloud Unable to run your workloads on-prem, in the cloud or on a third party service provider 1 2
  15. @BretMcG Serverless containers Secure on gVisor Fully managed BYO workloads

    Pay for use & stateless Alpha invitations coming later this year Sign up: g.co/serverlesscontainers New: serverless containers on GCF (EAP)
  16. @BretMcG Serverless anywhere Knative / GKE serverless addon On prem

    or multi-cloud Code or containers Custom hardware (GPU, TPU, IoT, etc) Offline You manage infra Serverless anywhere Managed by your cloud Container orchestration (k8s) Not serverless for programming or ops Container focused You manage infra Hosted FaaS/compute Easiest dev experience Code focused Limited runtime options Managed by your team Serverless containers Custom languages & runtimes Infra still cloud-managed
  17. @BretMcG Meet Knative: serverless on Kubernetes Kubernetes-based building blocks for

    serverless workloads Build - Serving - Events *kay-native
  18. @BretMcG Knative isn't Not an open source FaaS developer-facing product

    It's primitives, not a product Not the right solution for everyone
  19. @BretMcG Knative Build Serving Events Kubernetes + Istio 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
  20. @BretMcG *Sources: COCOMO Model, CNCF.io Certified Providers 442 Years of

    effort* 5,000+ Contributors 30k+ GitHub stars The incredible Kubernetes ecosystem
  21. @BretMcG Isolation: Keep jobs from interfering with each other Scheduling:

    Where should my job be run? Lifecycle: Keep my job running Discovery: Where is my job now? Constituency: Who is part of my job? Scale-up: Making my jobs bigger or smaller Auth{n,z}: Who can do things to my job? Monitoring: What’s happening with my job? Health: How is my job feeling? Container orchestration
  22. @BretMcG Developers using Kubernetes still have a lot to do

    Have to do Write code Build docker image Upload image to registry Deploy service Expose to the internet Setup logging & monitoring Scale workload Want to do Write code
  23. @BretMcG Reasons for using Kubernetes (2014) vs hosted serverless (2014)

    Reduce lock-in Performance Multi-cloud Customizability Use custom hardware (GPU, TPU, IoT, etc) Offline/reduced connectivity Existing on-prem infrastructure Existing applications
  24. @BretMcG Everybody got all fired up about Kubernetes and microservices

    and then were like ‘Oh s----, what’s going on?’ Istio lets us view our entire system and find trouble spots. Anonymous early adopter Observability:
  25. @BretMcG Example: canaries & traffic steering destination: pictures.example.local match: httpHeaders:

    user-agent: regex: ^(.*?;)?(iPhone)(;.*)?$ precedence: 2 route: - tags: version: 2.0-alpha env: staging pictures version: 2.0-alpha env: staging version: 1.5 env: prod Proxy Frontend Pictures Proxy Pictures Proxy
  26. @BretMcG Knative Serving defines principled objects Knative defines primitives with

    clear separation of concerns So far, we used Service, a lite version of Knative objects spec: container: image: gcr.io/knative-samples/simple-app:latest env: - name: SIMPLE_MSG value: "Hello Serverlessconf SF!" Service
  27. @BretMcG Configuration Service Knative Serving defines principled objects Knative defines

    primitives with clear separation of concerns Configuration Current/desired state for your application Code & configuration (separated, ala 12 factor)
  28. @BretMcG Revision Configuration Service Knative Serving defines principled objects Knative

    defines primitives with clear separation of concerns Configuration Current/desired state for your application Code & configuration (separated, ala 12 factor) Revision Point in time snapshots for your code and configuration
  29. @BretMcG Knative Serving defines principled objects Revision Knative defines primitives

    with clear separation of concerns Configuration Current/desired state for your application Code & configuration (separated, ala 12 factor) Revision Point in time snapshots for your code and configuration Route Maps traffic to a revisions Supports fractional, named routing Route Configuration Service
  30. @BretMcG Blue-green deployment model Route 100% Revision Configuration kind: Route

    ... spec: traffic: - revisionName: blue-green-00001 percent: 100
  31. @BretMcG Blue-green deployment model kind: Route ... spec: traffic: -

    revisionName: blue-green-00001 percent: 100 - revisionName: blue-green-00002 percent: 0 name: v2 Deploy updated version of the service • Blue continues to take 100% of traffic • Named route (v2) to green version Revision Route 100% Revision 0% v2 Configuration Configuration
  32. @BretMcG Blue-green deployment model Update service configuration • Send %

    of traffic to green • Still have explicit v2 route kind: Route ... spec: traffic: - revisionName: blue-green-00001 percent: 50 - revisionName: blue-green-00002 percent: 50 name: v2 Revision Route 98% Revision 2% (Experiment) Configuration Configuration Revision Route Revision Configuration Configuration
  33. @BretMcG Blue-green deployment model Update service configuration • Incrementally add

    %, until all traffic is on green • Keep explicit named route to blue Secured with RBAC-based ACL kind: Route ... spec: traffic: - revisionName: blue-green-00001 percent: 0 name: v1 - revisionName: blue-green-00002 percent: 100 Revision Route 0% v1 Revision 100% Configuration Configuration Revision Route Revision Configuration Configuration
  34. @BretMcG Blue-green deployment model Revision Route 0% v1 Revision 100%

    Configuration Configuration Revision Route Revision Configuration Configuration Demo: Deploying and updating live service
  35. @BretMcG More Knative pieces Knative Build enables source/git based deployments

    Knative Events compatible with CNCF standard Cloud Events Knative scales down when you don’t need it Knative scales up linearly with your load • Supports unpredictable usage pattern • 1-n when you app starts taking traffic
  36. @BretMcG Knative auto-builds Supports GitOps or src-to-URL development patterns Why

    developers care? • 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.
  37. @BretMcG Knative has opinions but is extensible Knative API •

    Event sources, event types • Buildpack build templates • Network configuration • Logging targets Some opinions may not be ideal for your use-case Kubernetes • Auto-scaling strategy • Function invokers • Message bus
  38. @BretMcG GKE serverless add-on Available for all later this year

    Request early access today at g.co/serverlessaddon GKE serverless add-on
  39. @BretMcG The goal is more serverless experiences for more developers.

    Even if it’s not perfectly serverless, happy devs will drive organizational change.
  40. @BretMcG Resources cloud.google.com/serverless Knative github.com/knative slack.knative.dev GKE serverless add-on (sign-up)

    g.co/serverlessaddon Containers on Cloud Functions (sign-up) g.co/serverlesscontainers Thank you! Bret McGowen @BretMcG