Architecture
Apex is a manifest-driven deployment orchestrator for TDengine All-in-One. This page explains its architecture, design decisions, and how components work together.
Overview
Section titled “Overview”flowchart TB
accTitle: Apex deployment architecture
accDescr: Deployment YAML and component manifests feed the Apex CLI workflow through check, validate, prepare, and apply. Local or SSH transport deploys components to target nodes.
config["Deployment YAML + Component Manifests"]
subgraph cli["Apex CLI (Controller)"]
direction LR
check --> validate --> prepare --> apply
end
subgraph transport["Transport Layer"]
direction LR
local["Local"]
ssh["SSH"]
end
subgraph targets["Target Nodes"]
direction LR
tsdb["TSDB"]
idmp["IDMP"]
tdgpt["TDgpt"]
cls["CLS"]
end
config --> cli
cli --> transport
transport --> targets
Core Components
Section titled “Core Components”CLI and Workflow Engine
Section titled “CLI and Workflow Engine”The Apex CLI (cmd/apex) provides the user interface and orchestrates the deployment workflow. It follows a stage-based approach:
- Check: Validates YAML syntax and tests node connectivity
- Validate: Loads manifests, resolves versions, checks dependencies
- Prepare: Downloads and verifies artifacts (SHA256)
- Apply: Distributes artifacts and executes lifecycle commands
Each stage can run independently, allowing operators to pause, inspect, and resume. The deploy command chains all four stages.
Configuration Layer
Section titled “Configuration Layer”Deployment YAML (kind: Deployment):
- Defines topology: nodes, platforms, transports
- Specifies component roles and versions
- Configures SSH credentials and paths
- Sets release profile and channel
Component Manifests:
- Published by component teams
- Declare supported platforms and dependencies
- Provide installers, resources, checksums
- Define lifecycle commands (pre-install, install, post-install)
User Configuration (~/.apex/config.yaml):
- Sets apex_home, base_url, telemetry preferences
- Shared across all deployments
Transport Layer
Section titled “Transport Layer”Apex supports two transport modes:
Local Transport (transport: local):
- Executes commands directly on the Apex host
- No SSH server required
- Ideal for single-node installations
- Uses filesystem operations for artifact placement
SSH Transport (transport: ssh):
- Connects to remote nodes via SSH
- Uploads artifacts through SFTP/SCP
- Executes commands remotely
- Supports key-based and password authentication
- Merges global and node-level SSH settings
Artifact Management
Section titled “Artifact Management”flowchart TB
accTitle: Artifact resolution and distribution
accDescr: Read artifact definitions from component manifests, download or import into the cache, verify SHA256, and distribute to nodes.
manifest["Component Manifest"] --> definition["Artifact Definition (URL, filename, SHA256)"]
definition --> download["Download / Import"]
download --> cache["Cache (~/.apex/cache)"]
cache --> verify["SHA256 Verification"]
verify --> distribute["Distribute to Nodes"]
Artifact Sources:
- Online: Downloaded from CDN (default: downloads.tdengine.com)
- Offline: Imported from local bundles
- Cached: Reused from previous preparations
Verification:
- Every artifact must match its manifest SHA256
- Required artifacts block deployment if missing
- Optional resources emit warnings when unavailable
Execution Model
Section titled “Execution Model”Apex executes deployment in dependency order:
- Dependency Resolution: Build execution graph from component dependencies
- Platform Selection: Choose platform-specific steps (linux-x64, windows-x64, etc.)
- Sequential Execution: Run lifecycle stages per component
- Transport Abstraction: Same commands work via local or SSH transport
Lifecycle Stages:
pre-install: Preparation steps (stop services, check dependencies)install: Main installation commandspost-install: Configuration and service startupuninstall: Removal stepspurge: Complete cleanup including data
Concurrency:
- Components deploy sequentially to honor dependencies
- Multiple nodes can receive artifacts in parallel
- Limited parallelism prevents resource contention
Directory Structure
Section titled “Directory Structure”~/.apex/ # Apex home (configurable)├── config.yaml # User configuration├── cache/ # Downloaded artifacts│ ├── artifacts/ # Component packages│ └── artifact-index.yaml # Verification index├── manifests/ # Component manifests│ ├── tsdb-manifest.yaml│ ├── idmp-manifest.yaml│ └── ...├── scripts/ # Lifecycle scripts│ ├── apex-util.sh│ └── apex-util.ps1├── logs/ # Operation logs│ └── deploy-20250115-123456/│ ├── apex.log # Main operation log│ └── node1-tsdb-install/ # Command evidence└── reports/ # Deployment reports └── deploy-20250115-123456/ └── report.yaml
/opt/apex/artifacts/ # Target node artifacts (Linux)C:\ProgramData\TDengine\Apex\ # Target node base (Windows)Version Resolution
Section titled “Version Resolution”Static Versions:
roles: - component: tsdb version: "3.3.5.0"Dynamic Versions:
spec: release: profile: all-in-one channel: stableroles: - component: tsdb version: autoDynamic resolution:
validatequeries the Version Catalog- Resolves
autoto specific versions per profile/channel - Emits a resolved Deployment YAML
prepareandapplyuse the resolved versions
This prevents version drift between stages.
Security Model
Section titled “Security Model”Authentication:
- SSH key-based authentication (recommended)
- SSH password authentication (less secure)
- Local transport requires appropriate user privileges
Artifact Integrity:
- All artifacts verified with SHA256 checksums
- Manifests digitally signed by component teams
- Download failures block deployment
Privilege Separation:
- Apex runs with user privileges on control host
- Target nodes may require root/administrator for installation
- Component services run under dedicated service accounts
Secrets Management:
- SSH credentials in Deployment YAML or config
- Passwords not logged or included in reports
- Private keys referenced by path, never embedded
Telemetry
Section titled “Telemetry”Apex includes best-effort telemetry to improve reliability:
- Anonymous usage data: deployment stages, durations, outcomes
- No sensitive data: no credentials, hostnames, or configuration
- Respects privacy: disabled with
telemetry_enabled: false - Never blocks: telemetry failures don’t affect deployment
Event flow:
flowchart TB
accTitle: Telemetry event flow
accDescr: One installation or deployment generates a shared runId, passes through bootstrap, prepare, apply, and validation stages, and sends events to the telemetry endpoint on a best-effort basis.
installer["Installer / Deploy"] --> runId["Generate runId"]
runId --> bootstrap["Stage 0 (bootstrap)"]
bootstrap --> prepare["Stage 1 (prepare)"]
prepare --> apply["Stage 2 (apply)"]
apply --> validation["Stage 3 (validation)"]
validation --> endpoint["Telemetry Endpoint (best-effort)"]
Design Decisions
Section titled “Design Decisions”Manifest-Driven
Section titled “Manifest-Driven”Why: Separates topology (what to deploy) from mechanics (how to install). Users maintain simple Deployment files; component teams own installation details.
Trade-off: Requires manifest distribution and version coordination.
Stage-Based Workflow
Section titled “Stage-Based Workflow”Why: Allows inspection between stages. Operators can review plans, verify artifacts, and pause before changes.
Trade-off: More commands for simple deployments (mitigated by deploy).
Dual Transport
Section titled “Dual Transport”Why: Single-node installations don’t need SSH complexity. Multi-node and remote deployments need proper remote execution.
Trade-off: Two code paths to maintain and test.
Sequential Component Deployment
Section titled “Sequential Component Deployment”Why: Honors dependencies cleanly. Simpler failure recovery.
Trade-off: Longer deployment time vs. full parallelism (acceptable for typical scales).
Artifact Verification
Section titled “Artifact Verification”Why: Prevents corrupted or tampered packages. Essential for production safety.
Trade-off: Cannot proceed with missing or invalid artifacts.
Extension Points
Section titled “Extension Points”While Apex is primarily a deployment tool, it provides hooks for customization:
Custom Scripts:
- Pre/post-install steps can call custom scripts
- Scripts deployed to target nodes via artifacts
Resource Management:
- Custom resources with install commands
- Platform-specific resource handling
Configuration Templates:
- Component configuration from templates
- Variable substitution in deployment
Related Topics
Section titled “Related Topics”- How Apex works - Workflow details and stage responsibilities
- Deployment YAML reference - Complete field definitions
- Best practices - Production deployment guidance
- Security guide - Hardening and secure configuration