Slide 1

Slide 1 text

Modernizing microservices with Cloud Run for Anthos a.k.a. how to get serverless in your Kubernetes cluster Anthos Day – KubeCon 2019, San Diego Monday, November 18, 2019

Slide 2

Slide 2 text

Ahmet Alp Balkan Developer Advocate @ahmetb Jason (Jay) Smith Customer Engineer @thejaysmith

Slide 3

Slide 3 text

Anthos Google Cloud Platform On-Premises Public Cloud Anthos GKE deployed on VMware Hub / Connect Anthos Config Management Anthos Service Mesh GKE Anthos GKE deployed on AWS Kubernetes Cluster GCP Marketplace Anthos Migrate ???

Slide 4

Slide 4 text

Anthos Google Cloud Platform On-Premises Public Cloud Anthos GKE deployed on VMware Hub / Connect Anthos Config Management Anthos Service Mesh GKE Anthos GKE deployed on AWS Kubernetes Cluster GCP Marketplace Anthos Migrate Cloud Run on Anthos

Slide 5

Slide 5 text

Serverless

Slide 6

Slide 6 text

Serverless Operational Model Programming Model No infra management No ops for scaling Managed security Pay per usage (request, etc) Service-based Request/event driven Stateless applications /

Slide 7

Slide 7 text

Serverless > Functions Compute Data Analytics ML & AI Database & Storage Smart assistants & chat DevOps Messaging

Slide 8

Slide 8 text

Serverless philosophy: efficient developers + efficient operators

Slide 9

Slide 9 text

Developers care about velocity, reproducibility, not doing infra

Slide 10

Slide 10 text

Cloud Run Run any stateless container on Google’s fully managed infrastructure

Slide 11

Slide 11 text

Container image to production URL in a few seconds Run services in any language or framework Fully-managed, rapid autoscaling, pay per request Cloud Run

Slide 12

Slide 12 text

01 Demo Cloud Run

Slide 13

Slide 13 text

✔ Legacy application deployment ✔ Fully managed, rapid autoscaling, scale-to-zero ✔ Production-ready, secured (HTTPS) endpoint What if you want these on your Kubernetes cluster? What we just saw

Slide 14

Slide 14 text

Serverless, on your terms Cloud Run (fully managed) • Serverless dev/operator experience • Runs on Google’s infrastructure • Pay-per-request Cloud Run for Anthos • Serverless developer experience • Runs in your Anthos/GKE cluster next to your Kubernetes workloads • Customizable/pluggable for your needs

Slide 15

Slide 15 text

GKE on GCP GKE on-prem Google infra Cloud Run for Anthos Knative GKE (Kubernetes) Knative API UI CLI YAML Cloud Run Developer & Operator

Slide 16

Slide 16 text

Knative Open source API and implementation that codifies "serverless on Kubernetes". Adds capabilities to Kubernetes to run stateless microservices more effectively. Heavily customizable and pluggable. Managed for you, with Cloud Run for Anthos. Has a strong community, backed by Google, Red Hat, IBM, SAP and other contributors. knative.dev knative.dev

Slide 17

Slide 17 text

Kubernetes Memory/CPU based autoscaling (slow) Knative Rapid, request-oriented autoscaling Handles traffic spikes Knative enhances Kubernetes Autoscaling More: https://ahmet.im/blog/knative-better-kubernetes-networking/

Slide 18

Slide 18 text

Kubernetes N/A Knative Scale application to 0, if no requests coming Activate (0→1) on the next request Knative enhances Kubernetes Scale to zero More: https://ahmet.im/blog/knative-better-kubernetes-networking/

Slide 19

Slide 19 text

Kubernetes Connection-based load balancing Knative Per-request load balancing Traffic splitting (blue/green deployments) Knative enhances Kubernetes Load Balancing More: https://ahmet.im/blog/knative-better-kubernetes-networking/

Slide 20

Slide 20 text

02 Demo Cloud Run for Anthos

Slide 21

Slide 21 text

What we just saw ✔ Same developer/ops experience as the fully-managed Cloud Run ✔ Knative installation, managed for you by Cloud Run for Anthos on GKE ✔ Traffic splitting, without writing YAML files ✔ Knative is still Kubernetes.

Slide 22

Slide 22 text

Migrating Kubernetes Deployments to Cloud Run

Slide 23

Slide 23 text

✓ Stateless applications (microservices, frontends, event handlers, queue processing) ✓ Listens on a port number with HTTP or gRPC. ✓ Ideally, doesn't take too long to start up and process requests. What’s good with Cloud Run?

Slide 24

Slide 24 text

apiVersion: apps/v1 kind: Deployment metadata: name: hello-web spec: replicas: 1 selector: matchLabels: app: hello tier: web template: metadata: labels: app: hello tier: web spec: containers: - name: main image: gcr.io/google-samples/hello-app:1.0 resources: limits: cpu: 100m memory: 256Mi Kubernetes Deployment Kubernetes Service apiVersion: v1 kind: Service metadata: name: hello-web labels: app: hello tier: web spec: type: ClusterIP selector: app: hello tier: web ports: - port: 80 targetPort: 8080

Slide 25

Slide 25 text

apiVersion: apps/v1 kind: Deployment metadata: name: hello-web spec: replicas: 1 selector: matchLabels: app: hello tier: web template: metadata: labels: app: hello tier: web spec: containers: - name: main image: gcr.io/google-samples/hello-app:1.0 resources: limits: cpu: 100m memory: 256Mi Kubernetes Deployment Kubernetes Service apiVersion: v1 kind: Service metadata: name: hello-web labels: app: hello tier: web spec: type: ClusterIP selector: app: hello tier: web ports: - port: 80 targetPort: 8080

Slide 26

Slide 26 text

apiVersion: apps/v1 kind: Deployment metadata: name: hello-web spec: replicas: 1 selector: matchLabels: app: hello tier: web template: metadata: labels: app: hello tier: web spec: containers: - name: main image: gcr.io/google-samples/hello-app:1.0 resources: limits: cpu: 100m memory: 256Mi Kubernetes Deployment Kubernetes Service apiVersion: v1 kind: Service metadata: name: hello-web labels: app: hello tier: web spec: type: ClusterIP selector: app: hello tier: web ports: - port: 80 targetPort: 8080

Slide 27

Slide 27 text

apiVersion: apps/v1 kind: Deployment metadata: name: hello-web spec: replicas: 1 selector: matchLabels: app: hello tier: web template: metadata: labels: app: hello tier: web spec: containers: - name: main image: gcr.io/google-samples/hello-app:1.0 resources: limits: cpu: 100m memory: 256Mi Kubernetes Deployment Kubernetes Service apiVersion: v1 kind: Service metadata: name: hello-web labels: app: hello tier: web spec: type: ClusterIP selector: app: hello tier: web ports: - port: 80 targetPort: 8080

Slide 28

Slide 28 text

apiVersion: apps/v1 kind: Deployment metadata: name: hello-web spec: replicas: 1 selector: matchLabels: app: hello tier: web template: metadata: labels: app: hello tier: web spec: containers: - name: main image: gcr.io/google-samples/hello-app:1.0 resources: limits: cpu: 100m memory: 256Mi Kubernetes Deployment Kubernetes Service apiVersion: v1 kind: Service metadata: name: hello-web labels: app: hello tier: web spec: type: ClusterIP selector: app: hello tier: web ports: - port: 80 targetPort: 8080

Slide 29

Slide 29 text

apiVersion: v1 kind: Service metadata: name: hello-web labels: app: hello tier: web spec: type: ClusterIP selector: app: hello tier: web ports: - port: 80 targetPort: 8080 apiVersion: apps/v1 kind: Deployment metadata: name: hello-web spec: replicas: 1 selector: matchLabels: app: hello tier: web template: metadata: labels: app: hello tier: web spec: containers: - name: main image: gcr.io/google-samples/hello-app:1.0 resources: limits: cpu: 100m memory: 256Mi Kubernetes Deployment Kubernetes Service

Slide 30

Slide 30 text

apiVersion: v1 kind: Service metadata: name: hello-web labels: app: hello tier: web spec: type: ClusterIP selector: app: hello tier: web ports: - port: 80 targetPort: 8080 apiVersion: apps/v1 kind: Deployment metadata: name: hello-web spec: replicas: 1 selector: matchLabels: app: hello tier: web template: metadata: labels: app: hello tier: web spec: containers: - name: main image: gcr.io/google-samples/hello-app:1.0 resources: limits: cpu: 100m memory: 256Mi Kubernetes Deployment Kubernetes Service

Slide 31

Slide 31 text

Knative Service = Kubernetes Deployment + Kubernetes Service apiVersion: apps/v1 kind: Deployment metadata: name: hello-web spec: replicas: 1 selector: matchLabels: app: hello tier: web template: metadata: labels: app: hello tier: web spec: containers: - name: main image: gcr.io/[...] resources: limits: cpu: 100m memory: 256Mi apiVersion: serving.knative.dev/v1alpha1 kind: Service metadata: name: hello-web spec: template: spec: containers: - image: gcr.io/[...] resources: limits: cpu: 100m memory: 256Mi

Slide 32

Slide 32 text

Knative Service = Kubernetes Deployment + Kubernetes Service apiVersion: serving.knative.dev/v1alpha1 kind: Service metadata: name: hello-web spec: template: spec: containers: - image: gcr.io/[...] resources: limits: cpu: 100m memory: 256Mi apiVersion: apps/v1 kind: Deployment metadata: name: hello-web spec: replicas: 1 selector: matchLabels: app: hello tier: web template: metadata: labels: app: hello tier: web spec: containers: - name: main image: gcr.io/[...] resources: limits: cpu: 100m memory: 256Mi

Slide 33

Slide 33 text

Serverless Eventing with Cloud Run and Kafka

Slide 34

Slide 34 text

I want to create a data driven organization. event

Slide 35

Slide 35 text

Knative eventing Benefits ● Declaratively bind between event producers and deployed services ● Scales from just few events to live streams ● Custom event pipelines to connect with your own existing systems

Slide 36

Slide 36 text

Knative Eventing

Slide 37

Slide 37 text

Knative Eventing

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

03 Demo Eventing with Kafka on Cloud Run for Anthos

Slide 40

Slide 40 text

Wrap-up: Cloud Run on Anthos ● Easier deployment and operations for microservices. ● Increased productivity and velocity. ● Enable your developers and operators.

Slide 41

Slide 41 text

Thanks! Resources ● cloud.run ○ anthos.dev ● knative.dev ○ github.com/ahmetb/cloud-run-faq ● gitlab.com/serverlessjay/cloud-run-eventing ○ knative.tips