Skip to content

Commit a2bc8ef

Browse files
committed
feat: service discovery improvements
1 parent cec64df commit a2bc8ef

File tree

9 files changed

+266
-252
lines changed

9 files changed

+266
-252
lines changed

config.integration.yaml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
# InferaDB Management API Configuration - Integration Tests
22
# This config is optimized for Docker container E2E testing
33

4-
frontend_base_url: "http://localhost:3000"
4+
frontend_base_url: "http://localhost:9090"
55

66
server:
7+
# Public REST API server
78
host: "0.0.0.0" # Bind to all interfaces for Docker
8-
port: 8081 # Match docker-compose exposed port
9+
port: 9090
10+
11+
# Public gRPC API server
912
grpc_host: "0.0.0.0"
10-
grpc_port: 8082
13+
grpc_port: 9091
14+
15+
# Internal/Private REST API server
16+
internal_host: "0.0.0.0"
17+
internal_port: 9092
18+
1119
worker_threads: 2 # Reduced for test environment
1220

1321
storage:
@@ -23,7 +31,7 @@ auth:
2331
webauthn:
2432
rp_id: "localhost"
2533
rp_name: "InferaDB Test"
26-
origin: "http://localhost:3000"
34+
origin: "http://localhost:9090"
2735

2836
email:
2937
smtp_host: "localhost"
@@ -45,16 +53,19 @@ observability:
4553
id_generation:
4654
worker_id: 0
4755

48-
server_api:
49-
grpc_endpoint: "http://server:8080" # Docker service name
56+
# Policy service (server) configuration for Kubernetes
57+
# Discovery mode discovers all server pod IPs
58+
policy_service:
59+
service_url: "http://inferadb-server.inferadb"
60+
grpc_port: 8081
61+
internal_port: 8082
5062
tls_enabled: false
5163

5264
identity:
5365
service_id: "management-integration-test"
5466
kid: "mgmt-test-2024"
5567

5668
cache_invalidation:
57-
server_internal_url: "http://inferadb-server.inferadb:9090"
5869
timeout_ms: 5000
5970
retry_attempts: 0
6071

config.production.yaml

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@
88

99
# Server configuration
1010
server:
11-
# HTTP server binding
11+
# Public REST API server binding
1212
host: "0.0.0.0"
13-
port: 3000
13+
port: 9090
1414

15-
# gRPC server binding
15+
# Public gRPC API server binding
1616
grpc_host: "0.0.0.0"
17-
grpc_port: 3001
17+
grpc_port: 9091
18+
19+
# Internal/Private REST API server binding
20+
internal_host: "0.0.0.0"
21+
internal_port: 9092
1822

1923
# Worker threads (recommended: number of CPU cores)
2024
worker_threads: 8
@@ -110,11 +114,20 @@ id_generation:
110114
# Example: ${WORKER_ID}
111115
worker_id: 0
112116

113-
# Server API (InferaDB policy engine) configuration
114-
server_api:
115-
# gRPC endpoint for policy engine
116-
# In production, use TLS-enabled endpoint
117-
grpc_endpoint: "https://policy-engine.example.com:8080"
117+
# Policy service (server) configuration
118+
# All server instances are discovered from this base URL + ports
119+
# In production with Kubernetes/Tailscale discovery, set discovery.mode appropriately
120+
policy_service:
121+
# Base service URL (without port)
122+
# For Kubernetes: use the k8s service name (e.g., "http://inferadb-server.inferadb")
123+
# For direct connection: use the host (e.g., "https://policy-engine.example.com")
124+
service_url: "https://policy-engine.example.com"
125+
126+
# gRPC port for policy engine communication
127+
grpc_port: 8081
128+
129+
# Internal/Private HTTP port for webhooks and JWKS
130+
internal_port: 8082
118131

119132
# Enable TLS for policy engine communication
120133
tls_enabled: true

config.yaml

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
# InferaDB Management API Configuration
22

33
# Frontend base URL for email verification and password reset links
4-
# Development: http://localhost:3000
4+
# Development: http://localhost:9090
55
# Production: https://app.inferadb.com
6-
frontend_base_url: "http://localhost:3000"
6+
frontend_base_url: "http://localhost:9090"
77

88
server:
9-
# Public server (client-facing traffic - web, CLI, SDK)
9+
# Public REST API server (client-facing traffic - web, CLI, SDK)
1010
host: "127.0.0.1"
11-
port: 3000
11+
port: 9090
1212

13-
# Internal server (server-to-server communication)
14-
# Always enabled for network-level security isolation
13+
# Public gRPC API server
14+
grpc_host: "127.0.0.1"
15+
grpc_port: 9091
16+
17+
# Internal/Private REST API server (server-to-server communication)
1518
# Runs a separate HTTP server for internal endpoints (JWKS)
1619
internal_host: "0.0.0.0"
17-
internal_port: 9091 # Server uses 9090, Management uses 9091
18-
19-
# gRPC server configuration
20-
grpc_host: "127.0.0.1"
21-
grpc_port: 3001
20+
internal_port: 9092
2221

2322
worker_threads: 4
2423

@@ -37,7 +36,7 @@ auth:
3736
webauthn:
3837
rp_id: "localhost"
3938
rp_name: "InferaDB"
40-
origin: "http://localhost:3000"
39+
origin: "http://localhost:9090"
4140
# Set via environment variable: INFERADB_MGMT__AUTH__KEY_ENCRYPTION_SECRET
4241
# key_encryption_secret: "your-secret-key-here"
4342

@@ -64,6 +63,10 @@ observability:
6463
id_generation:
6564
worker_id: 0
6665

67-
server_api:
68-
grpc_endpoint: "http://localhost:8080"
66+
# Policy service (server) configuration
67+
# All server instances are discovered from this base URL + ports
68+
policy_service:
69+
service_url: "http://localhost"
70+
grpc_port: 8081
71+
internal_port: 8082
6972
tls_enabled: false

crates/inferadb-management-api/src/handlers/auth.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,15 @@ id_generation:
195195
worker_id: 0
196196
max_clock_skew_ms: 1000
197197
198-
server_api:
199-
grpc_endpoint: "http://localhost:8080"
198+
policy_service:
199+
service_url: "http://localhost"
200+
grpc_port: 8080
201+
internal_port: 9090
200202
tls_enabled: false
201203
"#;
202204

203205
let config: ManagementConfig = serde_yaml::from_str(config_str).unwrap();
204-
let server_client = ServerApiClient::new("http://localhost:8080".to_string()).unwrap();
206+
let server_client = ServerApiClient::new("http://localhost".to_string(), 8080).unwrap();
205207

206208
// Create mock email service for testing
207209
let email_sender = Box::new(inferadb_management_core::MockEmailSender::new());

crates/inferadb-management-api/src/middleware/server_auth.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,11 @@ pub async fn require_server_jwt(
139139

140140
let kid = header.kid.ok_or_else(|| CoreError::Auth("JWT missing kid claim".to_string()))?;
141141

142-
// Derive server JWKS URL from server_api.grpc_endpoint
142+
// Derive server JWKS URL from policy_service config
143143
// The JWKS endpoint is at /.well-known/jwks.json on the server's internal port
144-
// server_api.grpc_endpoint typically points to the server's internal port
145144
let server_jwks_url = format!(
146145
"{}/.well-known/jwks.json",
147-
state.config.server_api.grpc_endpoint.trim_end_matches('/')
146+
state.config.effective_internal_url()
148147
);
149148

150149
// Fetch JWKS and find the key

0 commit comments

Comments
 (0)