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

Going Serverless, with Artifactory and Containers on Cloud Run

Going Serverless, with Artifactory and Containers on Cloud Run

cncf-canada-meetups

May 26, 2021
Tweet

More Decks by cncf-canada-meetups

Other Decks in Technology

Transcript

  1. Going Serverless with Artifactory and Containers on Cloud Run Guillaume

    Laforge Developer Advocate @ Google Ayrat Khayretdinov CNCF Ambassador, Hybrid Cloud Specialist @ Google @glaforge @archyufa
  2. Proprietary + Confidential The serverless models and characteristics Operational Model

    Programming Model No Infra Management Managed Security Pay only for usage Service-based Event-driven Stateless
  3. Proprietary + Confidential FaaS App platform Container Virtual machine The

    serverless spectrum Dedicated server Physical hardware Virtual hardware Operation system Application runtime Application Function Virtual hardware Operation system Application runtime Application Function Operation system Application runtime Application Function Application Function Function Serverless Zone
  4. Proprietary + Confidential Develop and deploy highly scalable containerized applications

    on a fully managed serverless platform • Write code your way using your favorite languages (Go, Python, Java, Ruby, Node.js, and more) • Abstract away all infrastructure management for a simple developer experience • Built upon an open standard Knative, enabling the portability of your applications Cloud Run
  5. Proprietary + Confidential Serverless containers with Knative and Cloud Run

    Cloud Run Fully managed, deploy your workloads and don’t see the cluster. Cloud Run on Anthos Deploy into Anthos, run serverless side-by-side with your existing workloads. Knative everywhere Use the same APIs and tooling anywhere you run Kubernetes with Knative.
  6. Proprietary + Confidential Containers Any language Rich ecosystem Any library

    of base images Any binary .js .rb .go .py .sh … 0 1 0 1 0 0 1 1 1 Containers Flexibility Serverless Velocity
  7. Proprietary + Confidential Container contract... and resources • Listen on

    0.0.0.0 on port $PORT (default 8080) • HTTP server must start < 4 min (timeout → 504) • Request time < 15 min (default → 5 min, up to 60 min) • Stateless (in-memory file system) • Computation only within request (No background activity) • 1 vCPU per container instance (configurable to 4 vCPU) • 256 MiB of memory up to a max of 8 GiB (configurable, soon 16 GiB) • 80 concurrent requests per container (configurable 1-80, soon 250) • 100 max containers by default (configurable 1-1000, support overridable) • Sandboxed by gVisor
  8. Proprietary + Confidential Billable time Instance Billable Time Request 1

    Start Request 1 End Request 2 Start Request 2 End Instance Time Billable Non-billable
  9. Gradual rollouts & Rollbacks Specify % traffic between revisions Blue

    / Green deployments Get URLs for specific revisions # Gradual rollout $ gcloud beta run deploy myservice \ --image gcr.io/project/image:f5bd774 \ --no-traffic \ --tag green $ gcloud beta run services update-traffic myservice \ --to-tags green=1 $ gcloud beta run services update-traffic myservice \ --to-tags green=10 $ gcloud beta run services update-traffic myservice \ --to-tags green=50 $ gcloud beta run services update-traffic myservice \ --to-tags green=100 # Rollback $ gcloud run services update-traffic myservice --to-revisions my-service-0002-joy=100 $ curl https://green---myservice-12345-us.a.run.app
  10. GCP Project VPC Access Connect to Cloud Memorystore Redis and

    Memcached Connect to private IPs Shared VPC Cloud Run Serverless VPC Connector Cloud Memorystore VM Compute Engine Virtual Private Cloud Private IP Private IP
  11. Cloud Workflows Orchestrate serverless tasks Fully managed. Use cases: •

    Process events • Chaining API calls • Automate infra management • Implement retry policies GCP Project Start Every day at 6pm Get list of all dev VMs End For each VM: Is it running ? Extract status Stop VM Email owner
  12. Min instances Keep a number of instances warm Use to

    avoid cold starts Lower instance price when not in use Container Instances min = 2 0
  13. Graceful instance termination Receive a SIGTERM signal before container instance

    is terminated. If handled, CPU is allocated for 10s max $ cat index.js const process = require('process'); process.on('SIGTERM', () => { console.log('Container is shutting down...'); // TODO: Close database connections // TODO: Send any buffered telemetry data }); ...
  14. gRPC support $ cat main.go … func main() { port

    := os.Getenv("PORT") listener, err := net.Listen("tcp", ":"+port) grpcServer := grpc.NewServer() pb.RegisterPingServiceServer(grpcServer, &pingService{}) if err = grpcServer.Serve(listener); err != nil { log.Fatal(err) } }
  15. Server-side streaming Server-Sent Events, WebSockets. Stream HTTP or gRPC responses

    Responses no more buffered and limited to 32MB $ cat main.go … http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "video/mp4") w.Header().Set("Transfer-Encoding", "chunked") f, _ := os.Open("videos/demo.mp4") io.Copy(w, f) }) port := os.Getenv("PORT") log.Fatal(http.ListenAndServe(fmt.Sprintf(":%s", port), nil)) (coming soon)
  16. Proprietary + Confidential Cloud Run Use cases More at https://cloud.run

    Serverless Use Cases Cloud Run Build a web or mobile app HTTP web app Bidirectional streaming WebSockets & gRPC Developing APIs Web & mobile backends Internal APIs and services Data Processing Automation Event driven reactive automation Workflow & Orchestration Event driven reactive automation Connecting Cloud Services Stateful Workloads ? Healthcare Gaming Retail Banking
  17. Cloud Run with Jfrog Demo Stack JFrog Cloud Platform on

    GCP - Jfrog Pipelines - Jfrog Docker Artifactory - Jfrog Xray Pull request Trigger Docker Repository CI CD Update Image tag Cloud Run Fully Managed Cloud Run for Anthos Thanks @jenn_viau for helping to build this amazing demo! Code Quality Build Image Scan Image
  18. Amazing Cloud Run Links • Slides - https://speakerdeck.com/cncfcanada • Awesome

    Cloud Run - github.com/steren/awesome-cloudrun • Cloud Run FAQ - github.com/ahmetb/cloud-run-faq • Vault on Cloud Run - gh/kelseyhightower/serverless-vault-with-cloud-run Guillaume Laforge Developer Advocate @ Google Ayrat Khayretdinov CNCF Ambassador, Hybrid Cloud Specialist @ Google @glaforge @archyufa
  19. THANK YOU! Guillaume Laforge Developer Advocate @ Google Ayrat Khayretdinov

    CNCF Ambassador, GDG, GDE Hybrid Cloud Specialist @ Google @glaforge @archyufa