Service Overview
Data Server
Internal API for direct database access
System API
API for system components (Duchies)
Public API
API for external clients (MCs, EDPs)
GCP Kingdom Data Server
Image:kingdom/data-serverService Name:
gcp-kingdom-data-serverPort: 8443 (gRPC), 8080 (health)
Purpose
The Kingdom Data Server is the internal API layer that provides direct access to the Kingdom’s Spanner database. It is not exposed externally and is only accessible to other Kingdom services within the cluster.Responsibilities
- Execute direct database operations against Cloud Spanner
- Provide CRUD operations for all Kingdom entities
- Manage database schema migrations via init containers
- Enforce data consistency and transaction boundaries
- Internal service-to-service communication only
Key Features
Schema Management
Schema Management
The Data Server deployment includes an init container (
update-kingdom-schema) that automatically runs schema migrations before the main server starts. This ensures the database schema is always up-to-date with the application code.Spanner Configuration
Spanner Configuration
The service is configured with Spanner connection parameters including:
- Instance ID
- Database name
- Project ID
- Connection pool settings
- Transaction timeout configurations
Protocol Configurations
Protocol Configurations
Loads protocol-specific configurations from mounted volumes:
- Liquid Legions V2 protocol config (
llv2_protocol_config_config.textproto) - Reach-Only LLv2 config (
ro_llv2_protocol_config_config.textproto) - HMSS protocol config (
hmss_protocol_config_config.textproto) - TrusTee protocol config (
trustee_protocol_config_config.textproto)
Configuration Flags
Network Policy
The Data Server only accepts connections from:v2alpha-public-api-serversystem-api-serverresource-setupjobs- Kingdom CronJobs (deletion, cancellation)
- Monitoring services (
operational-metrics,measurement-system-prober)
System API Server
Image:kingdom/system-apiService Name:
system-api-serverPort: 8443 (gRPC), 8080 (health)
Type: External Service
Purpose
The System API Server exposes gRPC services for system-level components including Duchies, simulators, and internal automation. It provides APIs for computation coordination and system administration.Key Services
The System API includes services for:Computations
System-level computation management and coordination
Computation Participants
Tracking duchy participation in measurements
Requisitions
System view of data requisitions
Certificates
Certificate lifecycle management
API Endpoints
Based on thesystem API package structure, the System API provides:
- ComputationsService: Query and update computation states
- ComputationParticipantsService: Manage duchy participation
- RequisitionsService: Track requisition fulfillment
- CertificatesService: Certificate validation and management
- DataProvidersService: System-level EDP operations
Authentication
Uses mutual TLS with certificate validation:- Duchy identity verified via TLS certificates
- Authority Key Identifier (AKID) mapping to principals
- Certificate collection for trusted roots
Configuration
Dependencies
The System API Server depends on:- gcp-kingdom-data-server: For database operations
- Spanner: Indirect dependency via Data Server
V2Alpha Public API Server
Image:kingdom/v2alpha-public-apiService Name:
v2alpha-public-api-serverPort: 8443 (gRPC), 8080 (health)
Type: External Service
Purpose
The Public API Server exposes the primary external API for Measurement Consumers and Event Data Providers. It provides the v2alpha version of the public CMMS API.Key Services
Located insrc/main/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/, the Public API includes:
Measurements
Create and manage measurement campaigns
Event Groups
Register and manage event data sources
Data Providers
EDP registration and management
Measurement Consumers
MC account and resource management
Complete Service List
The v2alpha Public API provides these gRPC services: Account Management:AccountsService: User account lifecycleApiKeysService: API key generation and managementClientAccountsService: Client account administration
MeasurementsService: Core measurement operationsMeasurementConsumersService: MC resource managementDataProvidersService: EDP resource management
EventGroupsService: Event group CRUD operationsEventGroupMetadataDescriptorsService: Metadata schema managementEventGroupActivitiesService: Track event group processing
CertificatesService: Certificate lifecycle and validation
ExchangesService: Panel exchange orchestrationExchangeStepsService: Individual exchange step managementExchangeStepAttemptsService: Track execution attempts
ModelProvidersService: Model provider registrationModelLinesService: Model line managementModelReleasesService: Model release trackingModelRolloutsService: Model deployment orchestrationModelSuitesService: Model suite configurationModelShardsService: Model sharding for scaleModelOutagesService: Track model availability
PopulationsService: Population definition and management
Authentication & Authorization
The Public API supports multiple authentication mechanisms:API Key Authentication
API Key Authentication
Implemented via
ApiKeyAuthenticationServerInterceptor, this allows clients to authenticate using API keys registered in the Kingdom.Account Authentication
Account Authentication
Session-based authentication via
AccountAuthenticationServerInterceptor for user accounts.Certificate-based (mTLS)
Certificate-based (mTLS)
Mutual TLS authentication using X.509 certificates with AKID-to-principal mapping.
Configuration Flags
Noise Mechanisms
The Public API supports differential privacy noise mechanisms:- NONE: No noise (for testing)
- CONTINUOUS_LAPLACE: Laplace noise for epsilon-DP
- CONTINUOUS_GAUSSIAN: Gaussian noise for (epsilon, delta)-DP
Dependencies
The Public API Server requires:- gcp-kingdom-data-server: Backend database operations
- ConfigMaps: Authority key identifier mapping and event group metadata types
Service Communication Flow
Deployment Details
All Kingdom services share common deployment characteristics:- Container Runtime: JVM-based (Kotlin)
- Health Checks: HTTP endpoint on port 8080
- Secrets Management: Kubernetes secrets for TLS certs and keys
- Configuration: ConfigMaps for protocol configs and mappings
- Init Containers: Schema migration before server start (Data Server only)
- Network Policies: Strict ingress/egress rules
Resource Allocation
Default resource requests/limits are defined in the base Kubernetes configuration. Services can be scaled horizontally based on load.Monitoring
All services expose:- gRPC health checks
- HTTP health endpoints
- Optional verbose logging for debugging
- OpenTelemetry instrumentation (when configured)
Security Considerations
Defense in Depth: The three-tier architecture (Data Server, System API, Public API) provides security isolation between internal operations, system components, and external clients.
- Minimal External Exposure: Only System API and Public API are externally accessible
- Certificate Validation: All connections use mutual TLS
- Network Policies: Kubernetes NetworkPolicies restrict traffic
- Secret Rotation: Secrets can be rotated without code changes
- Audit Logging: All API operations are logged
Next Steps
Kingdom Daemons
Learn about background jobs and scheduled tasks
Duchy Services
Explore services that coordinate with the Kingdom