Skip to content

rahulshendre/cloudrun-mvp

Repository files navigation

cloudrun-mvp

A minimal CLI that demonstrates the core CLOUDRUN_SYNC deployment flow against a real GCP Cloud Run service.

Built as proof of work for the GSoC 2026 proposal: GCP Cloud Run plugin for PipeCD v1.


What it demonstrates

The 6-step flow in main.go is a direct port of ensureSync() from the v0 PipeCD executor (pkg/app/piped/executor/cloudrun/deploy.go):

load service.yaml
  → compute revision name (image tag + commit hash)
  → set revision name in manifest  (spec.template.metadata.name)
  → set traffic split              (spec.traffic → [{revision: 100%}])
  → apply tracking labels          (pipecd-dev-managed-by, pipecd-dev-commit-hash, ...)
  → call GCP Cloud Run API         (Create if new, Update if exists)
  → poll revision readiness        (Ready=True, Active=True)
  → SUCCESS

This is the same logic that will live inside ExecuteStage() for the CLOUDRUN_SYNC stage in the v1 plugin (pkg/app/pipedv1/plugin/cloudrun/deployment/), with sdk.StageLogPersister replacing stdout and CloudRunDeployTargetConfig replacing the CLI flags.


File structure

File Source
manifest.go Ported from platformprovider/cloudrun/servicemanifest.go
client.go Ported from platformprovider/cloudrun/client.go + executor/cloudrun/cloudrun.go
main.go Mirrors ensureSync() in executor/cloudrun/deploy.go
service.yaml Minimal Cloud Run service manifest (uses public gcr.io/cloudrun/hello image)

Running it

Prerequisites:

  • GCP project with Cloud Run API enabled
  • gcloud auth application-default login (or a service account key file)
# Enable Cloud Run API
gcloud services enable run.googleapis.com --project=YOUR_PROJECT

# Authenticate
gcloud auth application-default login

# Deploy (first run — creates the service)
go run . --project=YOUR_PROJECT --region=us-central1 --commit-hash=abc1234

# Deploy again (second run — updates the service, new revision)
go run . --project=YOUR_PROJECT --region=us-central1 --commit-hash=def5678

Flags:

Flag Default Description
--project (required) GCP project ID
--region us-central1 Cloud Run region
--service-yaml service.yaml Path to service manifest
--credentials-file (none) Service account key JSON; uses ADC if omitted
--commit-hash random Commit hash for revision naming

Output

Run 1 — service created, revision hello-cloudrun-latest-abc1234 ready in 14s:

Run 1 terminal output

Run 2 — service updated, new revision hello-cloudrun-latest-def5678 ready in 13s:

Run 2 terminal output

GCP Console — two revisions, 100% traffic on the latest:

GCP Console revisions tab


Connection to the v1 plugin

The v0 code in platformprovider/cloudrun/ and executor/cloudrun/ is battle-tested but hardcoded into the piped binary. This MVP confirms that the core logic — manifest mutation, GCP API calls, revision polling — ports cleanly into a standalone module with no v0-specific dependencies.

In the v1 plugin, the same logic moves into ExecuteStage(), with two changes:

  • CLI flags → dts[0].Config (CloudRunDeployTargetConfig: project, region, credentialsFile)
  • log.Printfinput.Client.ReportStageLogs() via sdk.StageLogPersister

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages