memory-bank/components/ws-manager-api.md
The Workspace Manager API defines the gRPC interfaces for the Workspace Manager service, which is responsible for managing the lifecycle of workspaces within the Gitpod platform. This API enables the creation, monitoring, and control of workspaces running in Kubernetes clusters.
This API provides a standardized interface for:
The Workspace Manager API is implemented as a gRPC service defined in Protocol Buffer files. These definitions are used to generate client and server code in Go and TypeScript for use by the workspace manager and other components in the system.
Provides methods for managing workspaces:
GetWorkspaces: Retrieves a list of running workspaces and their statusStartWorkspace: Creates a new running workspace within the manager's clusterStopWorkspace: Stops a running workspaceDescribeWorkspace: Investigates a workspace and returns its status and configurationBackupWorkspace: Backs up a running workspaceSubscribe: Streams all status updates to a clientMarkActive: Records a workspace as being active, preventing it from timing outSetTimeout: Changes the default timeout for a running workspaceControlPort: Publicly exposes or un-exposes a network port for a workspaceTakeSnapshot: Creates a copy of the workspace content for initializing a new workspaceControlAdmission: Makes a workspace accessible for everyone or for the owner onlyDeleteVolumeSnapshot: Deletes a specific volume snapshotUpdateSSHKey: Updates SSH keys for a workspaceDescribeCluster: Provides information about the clusterRepresents the current status of a workspace:
Enum defining the high-level state of a workspace:
UNKNOWN: Cannot determine the actual phasePENDING: Workspace is waiting for resources in the clusterCREATING: Workspace is being created (downloading images)INITIALIZING: Workspace is executing the initializerRUNNING: Workspace is actively performing workINTERRUPTED: Workspace is temporarily unavailableSTOPPING: Workspace is shutting downSTOPPED: Workspace has ended regularlyDefines the runtime configuration of a workspace:
Defines the configuration for starting a workspace:
Describes a networking port exposed on a workspace:
Describes a workspace class supported by the cluster:
Subscribe method uses server-side streaming to provide real-time updatesThe API uses Protocol Buffers version 3 (proto3) syntax, which provides forward and backward compatibility features. The service is designed to allow for the addition of new workspace management features without breaking existing clients.
The Workspace Manager API uses Protocol Buffers and gRPC for defining interfaces. When changes are made to the .proto files, the corresponding code in Go and TypeScript needs to be regenerated.
To regenerate the code:
Navigate to the ws-manager-api directory:
cd components/ws-manager-api
Run the generate script:
./generate.sh
This script performs the following actions:
protoc-gen-go and protoc-gen-go-grpcAdditionally, the script:
mockgen for testingAfter regenerating the code, you may need to rebuild components that depend on the Workspace Manager API. This typically involves:
For Go components:
cd <component-directory>
go build ./...
For TypeScript components:
cd <component-directory>
yarn install
yarn build
Using Leeway (for CI/CD):
leeway build -D components/<component-name>:app
The Workspace Manager API is primarily used by the ws-manager-mk2 component, which is a Kubernetes controller for managing workspace lifecycle. It plays a critical role in the platform by enabling the creation, monitoring, and control of workspaces running in Kubernetes clusters.