Path: blob/main/memory-bank/components/ws-manager-mk2.md
2487 views
Workspace Manager MK2 Component
Overview
The Workspace Manager MK2 (ws-manager-mk2) is a Kubernetes controller responsible for managing the lifecycle of workspaces in Gitpod. It orchestrates the creation, monitoring, and deletion of workspace pods and related resources in the Kubernetes cluster.
Purpose
The primary purposes of the Workspace Manager MK2 are:
Manage the complete lifecycle of workspaces in Kubernetes
Implement workspace timeouts and resource management
Provide a gRPC API for workspace operations
Handle workspace status monitoring and updates
Coordinate with other components like content-service and registry-facade
Architecture
Workspace Manager MK2 is implemented as a Kubernetes controller using the controller-runtime framework. It consists of several key components:
Workspace Controller: Manages the Workspace custom resources
Timeout Controller: Handles workspace timeouts based on configuration
Maintenance Controller: Manages maintenance mode for workspaces
Subscriber Controller: Handles workspace event subscriptions
gRPC Service: Provides API for workspace operations
The component follows the Kubernetes operator pattern, watching for changes to Workspace custom resources and reconciling the actual state with the desired state.
Key Files and Structure
main.go
: Entry point that sets up the controller manager and gRPC servicecmd/
: Command-line interface implementationcontrollers/
: Kubernetes controllers for workspace resourcesservice/
: gRPC service implementationpkg/
: Supporting packages and utilitiesconfig/
: Configuration files, including CRD definitions
Dependencies
Internal Dependencies
components/common-go:lib
: Common Go utilitiescomponents/content-service-api/go:lib
: Content service API definitionscomponents/content-service:lib
: Content service clientcomponents/registry-facade-api/go:lib
: Registry facade API definitionscomponents/ws-manager-api/go:lib
: Workspace manager API definitionscomponents/image-builder-api/go:lib
: Image builder API definitions
External Dependencies
Kubernetes client-go: For interacting with the Kubernetes API
controller-runtime: Framework for building Kubernetes controllers
gRPC: For service communication
Prometheus: For metrics and monitoring
Configuration
Workspace Manager MK2 is configured via a JSON configuration file that includes:
Manager Configuration
Namespace settings for workspaces and secrets
Timeout configurations for different workspace states
URL templates for workspace access
TLS configuration for secure communication
Integration settings for other components
Content Storage Configuration
Storage backend configuration (Minio, GCloud)
Blob quota settings
RPC Server Configuration
Address and rate limits for the gRPC server
Monitoring Configuration
Prometheus metrics endpoint
Profiling endpoint
Integration Points
Workspace Manager MK2 integrates with:
Kubernetes API: For managing workspace resources
Content Service: For workspace content management
Registry Facade: For container image access
Image Builder: For custom workspace images
WS Daemon: For workspace runtime operations
Security Considerations
Implements TLS for secure gRPC communication
Manages workspace isolation through Kubernetes
Handles sensitive workspace configuration
Enforces resource limits and timeouts
Uses seccomp profiles for container security
Common Usage Patterns
Workspace Manager MK2 is typically used to:
Create new workspaces based on user requests
Monitor workspace status and health
Apply timeout policies to workspaces
Clean up workspace resources when no longer needed
Provide workspace status information to other components
Metrics and Monitoring
The component exposes Prometheus metrics for:
Workspace lifecycle operations
Request handling times
Resource usage
Error rates
Controller reconciliation metrics
Known Limitations
Requires specific Kubernetes RBAC permissions
Operates within a specific namespace, not cluster-wide
Depends on other Gitpod components for full functionality
Related Components
WS Daemon: Works with Workspace Manager to manage workspace runtime
Content Service: Manages workspace content
Registry Facade: Provides access to container images
Image Builder: Builds custom workspace images