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

How We Use Cloud Run and its Friends

How We Use Cloud Run and its Friends

Yuki Ito

July 13, 2022
Tweet

More Decks by Yuki Ito

Other Decks in Technology

Transcript

  1. What is Cloud Run Cloud Run is a managed compute

    platform that enables you to run containers that are invocable via requests or events. Cloud Run is serverless: it abstracts away all infrastructure management... https://cloud.google.com/run/docs
  2. Architecture - Key Concepts - e.g.) VS. Cloud Functions Trigger

    Run Pub/Sub Functions Run Firestore Functions
  3. Architecture ✅ Everything is Managed by API De fi nitions

    ✅ Reuse same implementation logic as APIs ✅ Use same Monitoring environments
  4. Job resource "google_pubsub_topic" "foo" { name = "foo" } resource

    "google_pubsub_subscription" "job-foo" { name = "job-foo" topic = google_pubsub_topic.foo.name push_config { push_endpoint = "<cloud run endpoint uri>" } }
  5. Job resource "google_project_iam_member" "pubsub-is-sa-token-creator" { project = "<project name>" role

    = "roles/iam.serviceAccountTokenCreator" member = "serviceAccount:service-<project number>@gcp-sa-pubsub... } roles/iam.serviceAccountTokenCreator
  6. Job resource "google_service_account" "job-api-invoker" { // ... account_id = "job-api-invoker"

    } resource "google_pubsub_subscription" "job-foo" { name = "job-foo" topic = google_pubsub_topic.foo.name push_config { push_endpoint = "<cloud run endpoint uri>" oidc_token { service_account_email = "job-api-invoker@..." audience = "<audience>" } } }
  7. Logging Container (Application) logs { "message": "grpc request", "logger": "grpc.request_logger",

    "method": "/customer.v1.CustomerService/GetXXX", "level": "info", "timestamp": 1613885945098.689 "logging.googleapis.com/trace": "projects/.../traces/xxx", } https://cloud.google.com/logging/docs/structured-logging
  8. Trace OpenTelemetry OpenTelemetry is a collection of tools, APIs, and

    SDKs. Use it to instrument, generate, collect, and export telemetry data (metrics, logs, and traces) to help you analyze your software’s performance and behavior. https://opentelemetry.io/