Skip to main content
Version: Next 🚧

Architecture Overview

TFRS Operator is built on Kubebuilder and manages the full lifecycle of TFRobot multi-tenant AI/robotics services through three levels of Custom Resource Definitions (CRDs).

Resource Model​

The Operator defines three CRD layers forming a top-down management structure:

TFRCluster (Cluster-scoped)
└── TFRTenant (Namespace-scoped)
└── TFRServer (Namespace-scoped)
CRDScopeResponsibility
TFRClusterClusterManages cluster-level infrastructure: Istio ingress, TLS certificates, Operator installation, image registry credentials
TFRTenantNamespaceConfigures tenant environments: databases, caching, object storage, message queues, monitoring stack
TFRServerNamespaceManages individual TFRobot service instances: API workers, robot workers, configuration and secrets

Multi-Tenancy Model​

TFRTenant supports two tenant types:

TypeDescriptionIsolation Level
enterpriseEnterprise tenant with dedicated namespaceFull isolation: independent network policies, storage, and middleware instances
personalPersonal tenant with shared namespace by job typeLogical isolation: differentiated by RobotId, shared middleware

Both types achieve network isolation through Istio PeerAuthentication (STRICT mTLS) and AuthorizationPolicy.

Infrastructure Components​

Cluster-Level (Installed by TFRCluster)​

ComponentDeployment MethodDescription
cert-managerHelm ChartAutomated TLS certificate management
IstioHelm ChartService mesh foundation
Istio Ingress GatewayHelm ChartIngress gateway, supports TKE CLB / NodePort / Docker Desktop
CNPG OperatorYAML ManifestCloudNativePG PostgreSQL Operator
MinIO OperatorHelm / YAMLMinIO object storage Operator
RabbitMQ OperatorYAML ManifestRabbitMQ Cluster and Topology Operator
Image Registry CredentialsSecretCross-namespace shared imagePullSecret

Tenant-Level (Instances Created by TFRTenant)​

ComponentDeployment MethodDescription
PostgreSQLCNPG Cluster CRPrimary database, 16-minimal-bookworm
RedisDeployment + PVCCache service (redis-stack-server)
MinIOMinIO Tenant CRObject storage
RabbitMQRabbitMQ Cluster CRMessage queue
TimescaleDBCNPG + ExtensionTime-series database
JaegerHelm ChartDistributed tracing
GrafanaHelm ChartMonitoring dashboard
PrometheusDeploymentMetrics collection
OTel CollectorDeploymentOpenTelemetry trace collection
VectorDeploymentLog collection
SharedCache PVCPVC (RWX)Shared image cache volume

Service-Level (Configured by TFRServer)​

ComponentDescription
API WorkerTFRobot API service
Robot WorkerRobot task Worker
DB Init JobDatabase schema initialization
MinIO Init JobStorage bucket initialization
Grafana SA JobGrafana service account setup
TOML ConfigConfz configuration auto-generation

Deployment Dependency Graph​

TFRCluster Component Deployment Order​

graph TD
CM[cert-manager] --> Istio
Istio --> IG[Istio Ingress]
IG --> GW[Gateway]
Istio --> EFC[EnvoyFilter Cookie]
Istio --> EFL[EnvoyFilter Lua Routing]
GW --> VS[ClusterVirtualService]
EFC --> VS
Istio --> IT[Istio Telemetry]

MO[MinIO Operator]
CO[CNPG Operator]
RO[RabbitMQ Operator]
IR[ImageRegistry]

cert-manager → Istio → Istio Ingress → Gateway/EnvoyFilter → VirtualService form a serial chain. The three middleware Operators and ImageRegistry can be installed in parallel.

TFRTenant Component Deployment Order​

graph TD
NS[Namespace] --> PG[PostgreSQL]
NS --> RD[Redis]
NS --> MN[MinIO]
NS --> JG[Jaeger]
NS --> PR[Prometheus]
NS --> VT[Vector]
NS --> SC[SharedCache PVC]
NS --> TF[TFRobotFront]
NS --> TU[TFRSUtils]

PG --> TD[TimescaleDB]
JG --> OT[OTel Collector]
RO_DEP[RabbitMQ Operator Ready] --> RQ[RabbitMQ]
NS --> GF[Grafana]

Most components can be deployed in parallel once the Namespace is created. TimescaleDB depends on PostgreSQL, OTel Collector depends on Jaeger, and RabbitMQ depends on the Operator being ready.

Credential Management​

TFRS Operator manages credentials at three levels:

LevelSecret ExampleDescription
TFRCluster{registry}-pull-secretImage registry pull credentials, shared across namespaces
TFRTenant{namespace}-pg-credentials, MinIO root credentialsMiddleware access credentials, auto-generated or user-specified
TFRServer{robot}-secret, {robot}-configApplication-level secrets (API Keys) and configuration

When password fields are not specified, the Operator automatically generates random passwords and stores them in Secrets.

ConfzData Auto-Configuration​

TFRServer uses ConfzData (TOML format) to manage application configuration. The Operator automatically injects middleware connection information:

# Auto-generated example (no manual input required)
[postgresql]
host = "{namespace}-pg-rw"
port = 5432
user = "app_user"
dbname = "{namespace}"

[redis]
host = "redis.{namespace}.svc.cluster.local"
port = 6379

[celery]
broker_url = "amqp://user:pass@rabbitmq.{namespace}.svc.cluster.local:5672/"

[cos]
host = "minio.{namespace}.svc.cluster.local"
port = 9000

Users can override any field via spec.confzData. Unspecified fields use Operator-generated dynamic values.

Environment Variable Injection​

TFRServer supports environment variable injection through secretData and configData:

Secret-type: OPENAI_API_KEY, ANTHROPIC_API_KEY, GOOGLE_GEMINI_API_KEY, etc.

Config-type (ConfigMap): OPENAI_BASE_URL, TFS_PROFILE, TFS_ROBOT__DB_SCHEMA, etc.

Auto-injected (highest priority): TFS_ROBOT__DOC_EXTRACTED_IMAGES_DIR is automatically injected from sharedCache.cacheDir, overriding any ConfigMap value of the same name.