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
280

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

    View Slide

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

    View Slide

  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
    ???

    View Slide

  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

    View Slide

  5. Serverless

    View Slide

  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
    /

    View Slide

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

    View Slide

  8. Serverless philosophy:
    efficient developers + efficient operators

    View Slide

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

    View Slide

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

    View Slide

  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

    View Slide

  12. 01
    Demo
    Cloud Run

    View Slide

  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

    View Slide

  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

    View Slide

  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

    View Slide

  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

    View Slide

  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/

    View Slide

  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/

    View Slide

  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/

    View Slide

  20. 02
    Demo
    Cloud Run
    for Anthos

    View Slide

  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.

    View Slide

  22. Migrating Kubernetes
    Deployments to Cloud Run

    View Slide

  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?

    View Slide

  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

    View Slide

  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

    View Slide

  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

    View Slide

  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

    View Slide

  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

    View Slide

  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

    View Slide

  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

    View Slide

  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

    View Slide

  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

    View Slide

  33. Serverless Eventing
    with Cloud Run and Kafka

    View Slide

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

    View Slide

  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

    View Slide

  36. Knative Eventing

    View Slide

  37. Knative Eventing

    View Slide

  38. View Slide

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

    View Slide

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

    View Slide

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

    View Slide