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

Modernizing microservices on Kubernetes with Cloud Run for Anthos/GKE

Ahmet Alp Balkan
November 18, 2019
120

Modernizing microservices on Kubernetes with Cloud Run for Anthos/GKE

How can you make your existing microservices apps on Kubernetes to make use of Knative (https://knative.dev) to take advantage of better autoscaling, load balancing, scale-to-zero and many other capabilities on a Google Anthos (https://anthos.dev) cluster.

Presented at Google’s Anthos Day @ KubeCon 2019 San Diego, CA by Ahmet Alp Balkan and Jason (Jay) Smith.

Ahmet Alp Balkan

November 18, 2019
Tweet

Transcript

  1. 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
  2. Ahmet Alp Balkan Developer Advocate @ahmetb Jason (Jay) Smith Customer

    Engineer @thejaysmith
  3. 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 ???
  4. 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
  5. Serverless

  6. 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 /
  7. Serverless > Functions Compute Data Analytics ML & AI Database

    & Storage Smart assistants & chat DevOps Messaging
  8. Serverless philosophy: efficient developers + efficient operators

  9. Developers care about velocity, reproducibility, not doing infra

  10. Cloud Run Run any stateless container on Google’s fully managed

    infrastructure
  11. 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
  12. 01 Demo Cloud Run

  13. ✔ 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
  14. 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
  15. GKE on GCP GKE on-prem Google infra Cloud Run for

    Anthos Knative GKE (Kubernetes) Knative API UI CLI YAML Cloud Run Developer & Operator
  16. 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
  17. 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/
  18. 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/
  19. 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/
  20. 02 Demo Cloud Run for Anthos

  21. 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.
  22. Migrating Kubernetes Deployments to Cloud Run

  23. ✓ 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?
  24. 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
  25. 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
  26. 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
  27. 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
  28. 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
  29. 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
  30. 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
  31. 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
  32. 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
  33. Serverless Eventing with Cloud Run and Kafka

  34. I want to create a data driven organization. event

  35. 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
  36. Knative Eventing

  37. Knative Eventing

  38. None
  39. 03 Demo Eventing with Kafka on Cloud Run for Anthos

  40. Wrap-up: Cloud Run on Anthos • Easier deployment and operations

    for microservices. • Increased productivity and velocity. • Enable your developers and operators.
  41. Thanks! Resources • cloud.run ◦ anthos.dev • knative.dev ◦ github.com/ahmetb/cloud-run-faq

    • gitlab.com/serverlessjay/cloud-run-eventing ◦ knative.tips