Path: blob/main/memory-bank/components/image-builder-mk3.md
2487 views
Image Builder MK3 Component
Overview
The Image Builder MK3 is a service that runs in Gitpod clusters and is responsible for building custom workspace images based on user-defined configurations. It provides APIs to create and list workspace image builds, resolve workspace Docker image references, and listen to build updates and logs.
Purpose
The primary purposes of the Image Builder MK3 are:
Build custom workspace images based on user-defined Dockerfiles
Manage the lifecycle of image builds
Provide APIs for creating and monitoring image builds
Resolve workspace Docker image references
Cache frequently used base images
Stream build logs to clients
Architecture
The Image Builder MK3 operates as a gRPC service with several key components:
Orchestrator: Manages the image build process
Reference Resolver: Resolves Docker image references
Build Manager: Handles build creation and status tracking
Log Streamer: Streams build logs to clients
Cache Manager: Manages caching of frequently used images
The service interacts with the Workspace Manager to coordinate image builds and with container registries to store and retrieve images.
Key Files and Structure
main.go
: Entry point that calls the Execute function from the cmd packagecmd/root.go
: Defines the root command and basic service configurationcmd/run.go
: Implements the main service functionalitypkg/orchestrator/
: Core orchestration logic for image buildspkg/resolve/
: Image reference resolution
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/image-builder-api/go:lib
: Image builder API definitionscomponents/supervisor-api/go:lib
: Supervisor API definitionscomponents/ws-manager-api/go:lib
: Workspace manager API definitionscomponents/registry-facade-api/go:lib
: Registry facade API definitions
External Dependencies
Docker registry client libraries
Kubernetes client libraries
gRPC for service communication
Prometheus for metrics
Configuration
The Image Builder MK3 is configured via a JSON configuration file that includes:
Orchestrator Configuration
Workspace Manager connection details
Pull secret for accessing private registries
Base image repository
Workspace image repository
Builder image reference
Reference Cache Configuration
Cache interval
References to cache
Server Configuration
gRPC server address and port
TLS settings
API Services
The Image Builder MK3 exposes a gRPC API that provides:
BuildImage: Initiates a new image build
ListBuilds: Lists existing image builds
BuildStatus: Retrieves the status of a specific build
BuildLogs: Streams logs from a build
ResolveWorkspaceImage: Resolves a workspace image reference
Build Process
The image build process follows these steps:
Client requests an image build via the API
Image Builder creates a build record and initiates the build
Builder container is created to execute the build
Build logs are streamed back to the client
Built image is pushed to the configured registry
Build status is updated and made available to clients
Integration Points
The Image Builder MK3 integrates with:
Workspace Manager: For workspace coordination
Container Registries: For storing and retrieving images
Kubernetes: For running builder containers
Content Service: For accessing workspace content
Security Considerations
Handles authentication with private registries
Requires proper IAM permissions when using cloud-based registries
Manages sensitive build context and credentials
Implements proper isolation for build processes
Common Usage Patterns
The Image Builder MK3 is typically used to:
Build custom workspace images from user-defined Dockerfiles
Resolve workspace image references for workspace creation
Monitor the progress of image builds
Stream build logs to users
Cache frequently used base images
Related Components
Workspace Manager: Coordinates with Image Builder for workspace creation
Registry Facade: Serves images built by Image Builder
Content Service: Provides content for image builds
Supervisor: Uses images built by Image Builder