Deployment Service
Durable deployment workflow orchestration
Deployment Service
The DeploymentService orchestrates the complete deployment lifecycle, from building containers to assigning domains.
Location: go/apps/ctrl/workflows/deploy/
Proto: go/proto/hydra/v1/deployment.proto
Key: project_id
Operations
Deploy
flowchart TD
  Start([Deploy Request]) --> FetchMeta[Fetch Metadata]
  FetchMeta --> StatusBuilding[Status: Building]
  StatusBuilding --> CreateKrane[Create in Krane]
  CreateKrane --> PollStatus{Poll Until Ready}
  PollStatus --> UpsertVMs[Upsert VM Records]
  UpsertVMs --> PollStatus
  PollStatus --> ScrapeAPI[Scrape OpenAPI Spec]
  ScrapeAPI --> BuildDomains[Build Domain List]
  BuildDomains --> AssignDomains[Call RoutingService]
  AssignDomains --> StatusReady[Status: Ready]
  StatusReady --> UpdateLive[Update Live Deployment]
  UpdateLive --> End([Complete])
  style AssignDomains fill:#e1f5fe
  style StatusReady fill:#c8e6c9
Creates a new deployment:
- Fetch deployment, workspace, project, environment metadata
 - Create deployment in Krane
 - Poll until instances are running
 - Scrape OpenAPI spec
 - Call RoutingService to assign domains atomically
 - Update project's live deployment ID
 
Implementation: go/apps/ctrl/workflows/deploy/deploy_handler.go
Rollback
flowchart TD
  Start([Rollback Request]) --> Validate[Validate Deployments]
  Validate --> CheckVMs[Check Target VMs]
  CheckVMs --> FindDomains[Find Sticky Domains]
  FindDomains --> SwitchDomains[Call RoutingService]
  SwitchDomains --> UpdateProject[Update Live Deployment]
  UpdateProject --> End([Success])
  style SwitchDomains fill:#e1f5fe
  style UpdateProject fill:#c8e6c9
Rolls back to a previous deployment:
- Validate source/target deployments
 - Find sticky domains (live + environment level)
 - Call RoutingService to switch domains atomically
 - Update project metadata
 
Implementation: go/apps/ctrl/workflows/deploy/rollback_handler.go
Promote
flowchart TD
  Start([Promote Request]) --> Validate[Validate Deployment]
  Validate --> FindDomains[Find All Domains]
  FindDomains --> SwitchDomains[Call RoutingService]
  SwitchDomains --> ClearFlag[Clear Rolled Back Flag]
  ClearFlag --> End([Success])
  style SwitchDomains fill:#e1f5fe
Promotes a deployment to live, removing rolled-back state:
- Validate deployment is ready
 - Find all project domains
 - Call RoutingService to reassign domains
 - Clear rolled_back flag
 
Implementation: go/apps/ctrl/workflows/deploy/promote_handler.go
Why RoutingService?
All domain/gateway operations are delegated to RoutingService to:
- Ensure atomic updates (gateway configs → domains)
 - Serialize domain operations per project
 - Provide rollback capabilities for failed routing changes