serverless on your own terms using knative context
play

Serverless On Your Own Terms Using Knative Context Serverless more - PowerPoint PPT Presentation

Serverless at Google @mchmarny Serverless On Your Own Terms Using Knative Context Serverless more than Function Serverless Models Operator No Infra Management Managed Security Pay only for usage Developer Service-based Event-driven Open


  1. Serverless at Google @mchmarny Serverless On Your Own Terms Using Knative

  2. Context

  3. Serverless more than Function

  4. Serverless Models Operator No Infra Management Managed Security Pay only for usage Developer Service-based Event-driven Open

  5. Serverless and Container

  6. Containers .js .rb .go • Any Language • Any Library .py .sh … • Any Binary • Ecosystem of base images 0 1 0 1 0 0 1 1 1

  7. Serverless with Poruability

  8. Kubernetes 442 Years of efgoru* 5,500+ Contributors 55k+ GitHub stars

  9. Kubernetes for operators Scheduling Lifecycle and health Naming and discovery Load balancing Storage volumes Platform over Logging and monitoring underlying infrastructure i.e. GKE Identity and authorization

  10. Kubernetes for developers Want to Have to Write code Build docker image locally Upload image to registry Deploy service Expose to the internet Setup logging & monitoring Scale workload...

  11. Knative

  12. Knative open source building blocks for serverless on Kubernetes [kay-native]

  13. Knative Primitives Developer-facing Products Build Serving Events ... Kubernetes

  14. Knative Momentum v0.1 v0.3 v0.5 v0.7 Initial release Container resources spec Expanded Event API v1beta1 API Serving, Build Updated scale-to-zero strategy GRPC streaming HPA-based scaling Cluster-local services Non-root containers July 18 Nov Jan 19 Feb Apr May July Upgradable configs Serving Beta API Pluggable networking, Mounting Secrets Auto-TLS autoscaling, and caching GRPC, HTTP/2, WebSockets EventType CRD v0.2 v0.4 v0.6

  15. Knative Community v0.7 55+ >6K Predictable Contributing Pull Requests Releases Companies ~450 9 Individual Working Contributors Groups

  16. Knative Today Google Cloud Run Red Hat OpenShifu SAP Kyma Products Google Cloud Run on GKE IBM Cloud Kubernetes Service TriggerMesh Primitives Serving Events Build Tekton ... Kubernetes Platform

  17. Knative Install

  18. Knative Stack Install Serverless Containers on GCF GKE Serverless Add-on SAP Kyma Products Pivotal Function Service IBM Cloud Functions Red Hat Cloud Functions Latest releases: https://knative.dev/docs/install/ Pivotal rifg OpenFaaS T-mobile Jazz $ kubectl apply \ -f https://github.com/knative/serving/releases/.../serving.yaml \ -f https://github.com/knative/eventing/releases/.../eventing.yaml \ Primitives Build Serving Events ... -f https://github.com/knative/monitoring/releases/.../monitoring.yaml \ -f https://github.com/knative/build/releases/.../build.yaml Istio Service Mesh Optionally apply individual event sources and channel provisioners Kubernetes Platform Confidential & Proprietary

  19. Install $ gcloud beta container \ clusters create my-cluster \ --addons=Istio,CloudRun Quick Start on GCP: bit.ly/cr-gke Also available for: ● AKS ● Docker ● Gardener ● IKS ● Minikube ● OpenShift/Minishift ● PCS Confidential & Proprietary

  20. Confjg $: kubectl get ns NAME STATUS default Active istio-system Active $: kubectl get cm -n knative-serving knative-build Active NAME DATA knative-eventing Active config-autoscaler 1 knative-monitoring Active config-defaults 1 knative-serving Active config-deployment 2 knative-sources Active config-domain 1 kube-public Active config-gc 1 kube-system Active config-istio 1 config-logging 1 config-network 6 config-observability 1 config-tracing 1 Confidential & Proprietary

  21. Knative Features

  22. Knative Serving Benefjts Integrations Connect with other GCP Activates and scales based on ● ● services like Cloud Build request (up/down to 0 pods) and Stackdriver Manages code/confjg revisions ● Extend with paruner (updates, rollbacks, traffjc splits) ● integrations like GitLab and Datadog Integrates service mesh ● (request path/services access control) Custom domains and ● SSL ceru supporu

  23. Deployment CLI release: github.com/knative/client kn service create service-name \ --image registry/image-name Result: service-name.namespace.domain.dev

  24. Deployment kubectl apply -f service.yaml # service.yaml apiVersion: serving.knative.dev/v1beta1 kind: Service metadata: name: service-name spec: template: spec: containers: - image: registry/image-name

  25. Deployment gcloud beta run deploy service-name \ --image=gcr.io/project/image-name Other CLIs: knctl, os, ibmcloud

  26. Autoscaling

  27. Deployment Options GitOps using Cloud Build, GitLab, Jenkins (e.g. branch or release triggers) github.com/mchmarny/maxprime/blob/master/deployments/cloudbuild.yaml Local Build uses Dockerfile, deploy using gcloud docker build/tag/publish gcloud beta run deploy app --image=gcr.io/project/image On-cluster Build (Build Templates or github.com/tektoncd/pipeline) kubectl apply -f build.yaml ko for quick iteration, no Dockerfile (golang only) github.com/google/ko ko apply -f config.yaml

  28. Day 2+ Service v1 v2

  29. Knative Object Model Service Route - named endpoint and a mechanism for routing traffjc Revisions - immutable snapshots of code + confjg Route Configuration Confjguration - stream of environments for Revisions Revision 3 Service - top-level wrapper for managing Route/Confjgurations sets Revision 2 Revision 1

  30. Simple Revision Management # List current revisions in demo namespace (filter on service name) kubectl get revisions -n demo -l serving.knative.dev/service=maxprime NAME SERVICE NAME GENERATION READY maxprime-vq25k maxprime-vq25k-service 3 True maxprime-wtz1g maxprime-wtz1g-service 2 True maxprime-qtz5p maxprime-qtz5p-service 1 True # Edit revision in service traffic section # (status/traffic[n]/revisionName) kubectl edit ksvc maxprime -n demo

  31. Blue/Green (deployment) apiVersion: serving.knative.dev/v1beta1 kind: Service metadata: name: bg 100% namespace: demo Service Revision spec: template: spec: containers: - image: gcr.io/knative-samples/knative-route-demo:blue github.com/mchmarny/knative-demos/tree/master/blue-green-deploy

  32. Blue/Green (update) spec: template: metadata: name: bg-2 100% - bg.demo.knative.tech ... Revision (bg-1) traffic: Service - tag: current revisionName: bg-1 Revision (bg-2) percent: 100 0% - bg-candidate.demo.knative.tech - tag: candidate revisionName: bg-2 percent: 0 - tag: latest latest Revision: true percent: 0 github.com/mchmarny/knative-demos/tree/master/blue-green-deploy

  33. Blue/Green (traffjc split) ... traffic: 60% 50% 40% - tag: current 30% revisionName: bg-1 20% 10% percent: 50 Revision (bg-2) - tag: candidate Service revisionName: bg-2 percent: 50 Revision (bg-1) - tag: latest 90% 80% latest Revision: true 70% percent: 0 60% 50% 40% github.com/mchmarny/knative-demos/tree/master/blue-green-deploy

  34. Blue/Green (rollback) ... traffic: - tag: previous revisionName: bg-1 0% percent: 100 Revision (bg-2) - tag: current Service revisionName: bg-2 percent: 0 Revision (bg-1) 100% - tag: latest latestRevision: true percent: 0 github.com/mchmarny/knative-demos/tree/master/blue-green-deploy

  35. Usage Patuerns Public Service Internal Service • Website • Mobile backend • Backing Microservices • API endpoint • Webhook • Eventing Targets

  36. Request Path Demo Kubernetes Cluster Knative HTTPS Logo Service Vision API HTTPS User curl -H "Content-Type: application/json" \ -d '{"id":"test","url":"https://storage.googleapis.com/kdemo-logos/k8s.png"}' \ -X POST https://klogo.demo.knative.tech/ | jq "."

  37. Request Path Demo Kubernetes Cluster Knative HTTPS Logo Service Vision API HTTP HTTPS Frontend UI HTTP HTTPS User User Service Firestore API OAuth demo

  38. Request Path Demo Kubernetes Cluster Knative HTTPS Logo Service Vision API HTTP HTTPS Frontend UI HTTP HTTPS User User Service Firestore API OAuth github.com/mchmarny/kdemo

  39. Request Path Demo Kubernetes Cluster Knative Logo Service HTTPS Vision API HTTP (cluster-local) Frontend UI HTTPS (external) HTTP User Service HTTPS User Firestore API (cluster-local) OAuth github.com/mchmarny/kdemo

  40. Request Path # github.com/mchmarny/klogo # service.yaml apiVersion: serving.knative.dev/v1alpha1 kind: Service metadata: name: klogo labels: serving.knative.dev/visibility: cluster-local ... github.com/mchmarny/kdemo

  41. Knative Eventing Benefjts Loosely coupled Orchestrates on/ofg cluster Use existing event sources ● ● event sources available or build your own Binds declaratively event Plugable channel ● ● sources, triggers, and services provisioners (e.g. PubSub. Kafla, NATS, In-Memory) Scales from just few events to ● live streaming pipelines Uses standard CloudEvents ● (CNCF Project)

Recommend


More recommend