* [server] Introduce ReadinessController and probe at /ready Tool: gitpod/catfood.gitpod.cloud * [server] Move /live and /ready endpoints to a separate express app and port Tool: gitpod/catfood.gitpod.cloud * [memory-bank] task-related learnings Tool: gitpod/catfood.gitpod.cloud * [server] Introduce `server_readiness_probe` feature flag so we can disable the ReadinessProbe if required Tool: gitpod/catfood.gitpod.cloud * docs: formalize Product Requirements Document workflow - Add PRD workflow to systemPatterns.md as a standardized development process - Update .clinerules with instructions to follow the PRD workflow - Update activeContext.md and progress.md to reference the new workflow This formalizes the process we used for implementing the server readiness probe feature. Tool: gitpod/catfood.gitpod.cloud * [server] ReadinessProbe: add redis as dependency Tool: gitpod/catfood.gitpod.cloud * review comments Tool: gitpod/catfood.gitpod.cloud * [dev] Remove outdated gopls config Tool: gitpod/catfood.gitpod.cloud * [server] Fix import Tool: gitpod/catfood.gitpod.cloud
8.6 KiB
System Patterns: Gitpod
System Architecture
Gitpod follows a microservices architecture composed of several key components that work together to provide the complete development environment platform. The system is designed to be:
- Scalable: Handles many concurrent users and workspaces
- Resilient: Maintains availability despite component failures
- Extensible: Allows for adding new features and integrations
- Secure: Isolates workspaces and protects user data
High-Level Architecture
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Git Platforms │ │ User Browser │ │ IDE Clients │
│ (GitHub, etc.) │ │ │ │ (VS Code, etc.)│
└────────┬────────┘ └────────┬────────┘ └────────┬────────┘
│ │ │
▼ ▼ ▼
┌─────────────────────────────────────────────────────────────────┐
│ API Gateway │
└─────────────────────────────────────────────────────────────────┘
│ │ │
▼ ▼ ▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Auth Service │ │ Dashboard │ │ IDE Service │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │
└───────────────┬───────┴───────────────┬───────┘
│ │
▼ ▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ WS Manager │ │ Image Builder │ │ Content Service│
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │
▼ ▼ ▼
┌─────────────────────────────────────────────────────────────────┐
│ Kubernetes Infrastructure │
└─────────────────────────────────────────────────────────────────┘
Key Components
Core Services
-
Workspace Manager (ws-manager): Orchestrates workspace lifecycle, managing creation, starting, stopping, and deletion of workspaces.
-
Workspace Daemon (ws-daemon): Runs on each node, managing workspace resources, file system operations, and runtime aspects.
-
Image Builder: Builds Docker images for workspaces based on configuration and caches them for quick startup.
-
Content Service: Manages file content, including git operations, file synchronization, and backup.
-
IDE Service: Manages the IDE instances (VS Code, JetBrains) that run in workspaces.
-
Dashboard: Web UI for managing workspaces, projects, and user settings.
-
Auth Service: Handles authentication and authorization across the platform.
-
Proxy: Routes traffic to the appropriate services and workspaces.
Supporting Components
-
Registry Facade: Provides efficient access to container images.
-
Blobserve: Serves static content from container images.
-
Supervisor: Runs inside each workspace, managing the workspace's internal services.
-
Public API: Provides programmatic access to Gitpod functionality.
Design Patterns
Microservices Pattern
Gitpod is built as a collection of loosely coupled services, each with a specific responsibility. This enables independent scaling, deployment, and maintenance of components.
Container Orchestration
Kubernetes is used to manage the deployment, scaling, and operation of application containers across clusters of hosts.
Event-Driven Architecture
Components communicate through events for asynchronous operations, improving scalability and resilience.
API Gateway Pattern
A central API gateway routes requests to appropriate services, handling cross-cutting concerns like authentication.
Circuit Breaker Pattern
Services implement circuit breakers to prevent cascading failures when downstream services are unavailable.
Sidecar Pattern
The Supervisor component runs alongside workspace applications as a sidecar, providing common functionality.
Immutable Infrastructure
Workspaces are treated as immutable, with changes to configuration resulting in new environments rather than modifications to existing ones.
Component Relationships
Workspace Lifecycle
- User requests a workspace through the dashboard or Git integration
- Auth service validates the request
- Workspace Manager creates the workspace specification
- Image Builder ensures the required image is available
- Workspace Manager instructs Kubernetes to create the workspace pod
- Workspace Daemon initializes the workspace environment
- Supervisor starts within the workspace
- IDE Service connects the IDE to the workspace
- Proxy routes user traffic to the workspace
Data Flow
- User Code: Managed by Content Service, synchronized between workspace and git repositories
- Configuration: Stored in database, applied by Workspace Manager during workspace creation
- Build Artifacts: Cached by Image Builder for reuse in future workspaces
- User Data: Stored in database, accessed through Dashboard and API
Key Technical Decisions
-
Kubernetes-Based: Leveraging Kubernetes for container orchestration provides scalability and standardized infrastructure management.
-
Multi-IDE Support: Supporting multiple IDEs (VS Code, JetBrains) increases flexibility for users with different preferences.
-
Prebuild System: Prebuilding environments before they're needed significantly reduces startup times.
-
Workspace Pods: Each workspace runs in its own Kubernetes pod, providing isolation and resource management.
-
TypeScript and Go: Core services are implemented in TypeScript (user-facing) and Go (system-level), balancing developer productivity and performance.
-
gRPC Communication: Internal services communicate using gRPC for efficient, typed communication.
-
Leeway Build System: Custom build system for managing the complex dependencies between components.
-
Kubernetes Deployment Configuration: All code that defines Kubernetes objects for deployable components lives in
install/installer. This centralized approach ensures consistent deployment patterns across all components.
Development Workflows
Product Requirements Document (PRD) Workflow
Gitpod uses a structured PRD workflow for feature development to ensure proper planning, documentation, and implementation:
- Requirements Gathering (Plan Mode): Understand the problem, explore existing components, gather information
- PRD Creation (Plan Mode): Create a detailed document in
prd/with standardized sections - Implementation Planning (Plan Mode): Identify files to modify and plan the approach
- Implementation (Act Mode): Create/modify necessary files following the plan
- Documentation Update (Act Mode): Update memory bank with new knowledge
- Verification: Ensure implementation meets requirements and documentation is complete
This workflow ensures thorough planning, clear documentation, and knowledge preservation for all feature development.