How openshift/assisted-image-service works
Project Overview
• Project Type: It is a specialized backend service designed to customize and serve RHCOS images for the Assisted Installer Service. The service downloads images on startup and provides multiple API endpoints for different authentication modes and image variants.
• Key Purpose: It takes in configuration, downloads RHCOS images, and then exposes endpoints to deliver customized images. It also interacts with an external assisted service for information.
Identifying the Main Components
a. HTTP API Server:
• Located in the root (main.go) and organized through the internal/handlers directory.
• Exposes multiple endpoints (e.g., /byid, /bytoken, /byapikey, /images, /boot-artifacts, /health, /live, /metrics).
• Handles authentication logic and token transformations between client requests and assisted service requests.
b. Image Customization Modules:
• The pkg/isoeditor package performs image editing functions (e.g., appending ignition, modifying boot parameters).
• The pkg/imagestore package handles storage and retrieval of downloaded RHCOS images.
• Additional supporting packages include pkg/overlay (managing overlays for images) and pkg/servers.
c. Assisted Service Integration:
• The service integrates with an external assisted service (its address and scheme are provided via environment variables).
• The authentication mapping (e.g., api_key, image_token, Authorization) is a key feature.
d. Configuration and Environment:
• Environment variables and configuration files (via README) set parameters like DATA_DIR, CERT paths, ports, version details, etc.
• Directories ‘data’ and ‘data_temp’ play a central role in storing downloaded images and temporary extraction data.
e. Deployment & Build Infrastructure:
• Dockerfiles (multiple, e.g., Dockerfile.image-service, Dockerfile.image-service-mce) and Makefile indicate containerized deployment.
• CI/CD configurations (e.g., .ci-operator.yaml, .github, .tekton) and integration tests in integration_test.
• Package management (go.mod, go.sum) which outlines the service’s dependencies.
Components’ Relationships and Interactions
• The HTTP layer (main API server) dispatches requests to the internal handlers.
• Handlers then interact with the image customization (pkg/isoeditor) and image storage logic (pkg/imagestore).
• When a request requires information or token translation, the service establishes outbound connections to the assisted service.
• The system initialization includes a startup process that downloads a set of images based on the provided configuration.
• Health, liveness, and metrics endpoints indicate readiness and performance, connecting to standard observability practices.
Architectural Patterns and Design Principles
• Modular design using packages: Handlers separate the web API logic from the business logic in packages like isoeditor and imagestore.
• Clean separation of concerns: API routing, authentication handling, image processing, and external service integration are clearly separated.
• Containerization and CI/CD integration are evident, suggesting a DevOps-friendly deployment pipeline.