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
360

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. 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 ???
  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 Cloud Run on Anthos
  4. 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 /
  5. Serverless > Functions Compute Data Analytics ML & AI Database

    & Storage Smart assistants & chat DevOps Messaging
  6. 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
  7. ✔ 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
  8. 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
  9. GKE on GCP GKE on-prem Google infra Cloud Run for

    Anthos Knative GKE (Kubernetes) Knative API UI CLI YAML Cloud Run Developer & Operator
  10. 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
  11. 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/
  12. 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/
  13. 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/
  14. 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.
  15. ✓ 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?
  16. 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
  17. 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
  18. 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
  19. 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
  20. 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
  21. 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
  22. 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
  23. 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
  24. 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
  25. 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
  26. Wrap-up: Cloud Run on Anthos • Easier deployment and operations

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

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