Skip to content

Latest commit

 

History

History
191 lines (180 loc) · 21.5 KB

File metadata and controls

191 lines (180 loc) · 21.5 KB

Cloud SDK ↔ Control Plane Integration Architecture

This document describes how the Brev control plane integrates with the Cloud SDK to manage GPU infrastructure across multiple cloud providers.


Swimlane: Inventory Sync Flow (Background)

This flow runs continuously in the background to keep Brev's catalog synchronized with cloud provider availability.

┌─────────────────┐    ┌─────────────────────┐    ┌──────────────────────┐    ┌──────────────────┐
│    Workflow     │    │    Control Plane    │    │     Cloud SDK        │    │  Cloud Provider  │
│                 │    │   Syncer Layer      │    │   CloudClient        │    │      API         │
└────────┬────────┘    └──────────┬──────────┘    └──────────┬───────────┘    └────────┬─────────┘
         │                        │                          │                         │
         │                        │                          │                         │
═══════════════════════════════════════════════════════════════════════════════════════════════════
         │      INSTANCE TYPE SYNC (Inventory Sync)          │                         │
═══════════════════════════════════════════════════════════════════════════════════════════════════
         │                        │                          │                         │
         │  Tick: pollTime        │                          │                         │
         ├───────────────────────►│                          │                         │
         │                        │                          │                         │
         │                        │  GetAPIType()            │                         │
         │                        ├─────────────────────────►│                         │
         │                        │◄─────────────────────────┤                         │
         │                        │  "global" | "locational" │                         │
         │                        │                          │                         │
         │                        │         ┌────────────────┴────────────────┐        │
         │                        │         │  IF APIType == "locational"     │        │
         │                        │         └────────────────┬────────────────┘        │
         │                        │                          │                         │
         │                        │  GetLocations()          │                         │
         │                        ├─────────────────────────►│  GET /locations         │
         │                        │                          ├────────────────────────►│
         │                        │                          │◄────────────────────────┤
         │                        │◄─────────────────────────┤  []Location             │
         │                        │                          │                         │
         │                        │  (for each location)     │                         │
         │                        │  GetInstanceTypes(loc)   │                         │
         │                        ├─────────────────────────►│  GET /instance-types    │
         │                        │                          ├────────────────────────►│
         │                        │                          │◄────────────────────────┤
         │                        │◄─────────────────────────┤  []InstanceType         │
         │                        │                          │                         │
         │                        │         ┌────────────────┴────────────────┐        │
         │                        │         │  IF APIType == "global"         │        │
         │                        │         └────────────────┬────────────────┘        │
         │                        │                          │                         │
         │                        │  GetInstanceTypes("all") │                         │
         │                        ├─────────────────────────►│  GET /instance-types    │
         │                        │                          ├────────────────────────►│
         │                        │                          │◄────────────────────────┤
         │                        │◄─────────────────────────┤  []InstanceType         │
         │                        │                          │                         │
         │                        │                          │                         │
         │                        │                          │                         │
         │                        │                          │                         │
         │                        │                          │                         │
═══════════════════════════════════════════════════════════════════════════════════════════════════
         │      INSTANCE STATUS SYNC (State of an Instance Sync)                       │
═══════════════════════════════════════════════════════════════════════════════════════════════════
         │                        │                          │                         │
         │  Tick: 5 sec           │                          │                         │
         ├───────────────────────►│                          │                         │
         │                        │                          │                         │
         │                        │  MakeClient(location)    │                         │
         │                        ├─────────────────────────►│                         │
         │                        │◄─────────────────────────┤  CloudClient            │
         │                        │                          │                         │
         │                        │  ListInstances()         │                         │
         │                        ├─────────────────────────►│  GET /instances         │
         │                        │                          ├────────────────────────►│
         │                        │                          │◄────────────────────────┤
         │                        │◄─────────────────────────┤  []Instance             │
         │                        │                          │                         │
         │                        │                          │                         │
         │                        │                          │                         │
         ▼                        ▼                          ▼                         ▼

Swimlane: Provisioning Flow (User-Triggered)

This flow handles user requests to create, terminate, stop, or start instances.

┌─────────────┐  ┌──────────────┐  ┌────────────────┐  ┌─────────────────┐  ┌──────────────────┐
│    User     │  │ Control Plane│  │ Control Plane  │  │    Cloud SDK    │  │  Cloud Provider  │
│  (API Call) │  │   API Layer  │  │ Service Layer  │  │   CloudClient   │  │      API         │
└──────┬──────┘  └──────┬───────┘  └───────┬────────┘  └────────┬────────┘  └────────┬─────────┘
       │                │                  │                    │                    │
       │                │                  │                    │                    │
═══════════════════════════════════════════════════════════════════════════════════════════════════
       │      CREATE INSTANCE                                                        │
═══════════════════════════════════════════════════════════════════════════════════════════════════
       │                │                  │                    │                    │
       │  POST /instance│                  │                    │                    │
       ├───────────────►│                  │                    │                    │
       │                │                  │                    │                    │
       │                │  CreateInstance()│                    │                    │
       │                ├─────────────────►│                    │                    │
       │                │                  │                    │                    │
       │                │                  │  GetCloudClient    │                    │
       │                │                  │  (credID, location)│                    │
       │                │                  ├───────────────────►│                    │
       │                │                  │◄───────────────────┤ CloudClient        │
       │                │                  │                    │                    │
       │                │                  │  CreateInstance    │                    │
       │                │                  │  (CreateInstanceAttrs)                  │
       │                │                  ├───────────────────►│                    │
       │                │                  │                    │                    │
       │                │                  │                    │  POST /instances   │
       │                │                  │                    │  {                 │
       │                │                  │                    │    region,         │
       │                │                  │                    │    instance_type,  │
       │                │                  │                    │    ssh_keys,       │
       │                │                  │                    │    ...             │
       │                │                  │                    │  }                 │
       │                │                  │                    ├───────────────────►│
       │                │                  │                    │◄───────────────────┤
       │                │                  │                    │  Instance          │
       │                │                  │◄───────────────────┤  (CloudID, IP,     │
       │                │                  │  *Instance         │   Status, ...)     │
       │                │                  │                    │                    │
       │                │                  │                    │                    │  
       │                │                  │                    │                    │
       │                │◄─────────────────┤  Instance          │                    │
       │◄───────────────┤  201 Created     │                    │                    │
       │                │                  │                    │                    │
       │                │                  │                    │                    │
═══════════════════════════════════════════════════════════════════════════════════════════════════
       │      TERMINATE INSTANCE                                                     │
═══════════════════════════════════════════════════════════════════════════════════════════════════
       │                │                  │                    │                    │
       │  DELETE        │                  │                    │                    │
       │  /instance/{id}│                  │                    │                    │
       ├───────────────►│                  │                    │                    │
       │                │                  │                    │                    │
       │                │  TerminateWorkflow                    │                    │
       │                ├─────────────────►│                    │                    │
       │                │                  │                    │                    │
       │                │                  │  GetCloudClient    │                    │
       │                │                  ├───────────────────►│                    │
       │                │                  │◄───────────────────┤                    │
       │                │                  │                    │                    │
       │                │                  │  TerminateInstance │                    │
       │                │                  │  (CloudProviderID) │                    │
       │                │                  ├───────────────────►│                    │
       │                │                  │                    │  DELETE            │
       │                │                  │                    │  /instances/{id}   │
       │                │                  │                    ├───────────────────►│
       │                │                  │                    │◄───────────────────┤
       │                │                  │◄───────────────────┤  nil (success)     │
       │                │                  │                    │                    │
       │                │◄─────────────────┤                    │                    │
       │◄───────────────┤  200 OK          │                    │                    │
       │                │                  │                    │                    │
       │                │                  │                    │                    │
═══════════════════════════════════════════════════════════════════════════════════════════════════
       │      STOP / START INSTANCE (if supported)                                   │
═══════════════════════════════════════════════════════════════════════════════════════════════════
       │                │                  │                    │                    │
       │  POST          │                  │                    │                    │
       │  /instance/{id}│                  │                    │                    │
       │  /stop         │                  │                    │                    │
       ├───────────────►│                  │                    │                    │
       │                │                  │                    │                    │
       │                │  StopWorkflow    │                    │                    │
       │                ├─────────────────►│                    │                    │
       │                │                  │                    │                    │
       │                │                  │  GetCapabilities() │                    │
       │                │                  ├───────────────────►│                    │
       │                │                  │◄───────────────────┤ [StopStart, ...]   │
       │                │                  │                    │                    │
       │                │                  │  IF capable:       │                    │
       │                │                  │  StopInstance(id)  │                    │
       │                │                  ├───────────────────►│  POST /stop        │
       │                │                  │                    ├───────────────────►│
       │                │                  │                    │◄───────────────────┤
       │                │                  │◄───────────────────┤                    │
       │                │◄─────────────────┤                    │                    │
       │◄───────────────┤  200 OK          │                    │                    │
       │                │                  │                    │                    │
       ▼                ▼                  ▼                    ▼                    ▼