Skip to main content

orca_core/config/
cluster.rs

1use std::collections::HashMap;
2
3use serde::{Deserialize, Serialize};
4
5use super::ai::AiConfig;
6use crate::backup::BackupConfig;
7
8/// Top-level cluster configuration (`cluster.toml`).
9#[derive(Debug, Clone, Serialize, Deserialize)]
10pub struct ClusterConfig {
11    pub cluster: ClusterMeta,
12    #[serde(default)]
13    pub node: Vec<NodeConfig>,
14    #[serde(default)]
15    pub observability: Option<ObservabilityConfig>,
16    #[serde(default)]
17    pub ai: Option<AiConfig>,
18    #[serde(default)]
19    pub backup: Option<BackupConfig>,
20    /// API bearer tokens for authentication. Empty = allow all requests.
21    #[serde(default)]
22    pub api_tokens: Vec<String>,
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
26pub struct ClusterMeta {
27    pub name: String,
28    pub domain: Option<String>,
29    pub acme_email: Option<String>,
30    #[serde(default = "default_log_level")]
31    pub log_level: String,
32    #[serde(default = "default_api_port")]
33    pub api_port: u16,
34    #[serde(default = "default_grpc_port")]
35    pub grpc_port: u16,
36}
37
38pub(crate) fn default_log_level() -> String {
39    "info".into()
40}
41
42pub(crate) fn default_api_port() -> u16 {
43    6880
44}
45
46pub(crate) fn default_grpc_port() -> u16 {
47    6881
48}
49
50#[derive(Debug, Clone, Serialize, Deserialize)]
51pub struct NodeConfig {
52    pub address: String,
53    #[serde(default)]
54    pub labels: HashMap<String, String>,
55    /// GPU devices available on this node.
56    #[serde(default)]
57    pub gpus: Vec<NodeGpuConfig>,
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
61pub struct NodeGpuConfig {
62    /// Vendor: "nvidia" or "amd".
63    pub vendor: String,
64    /// Number of GPUs of this type.
65    #[serde(default = "default_gpu_count")]
66    pub count: u32,
67    /// Model name for scheduling (e.g., "A100", "RTX4090").
68    pub model: Option<String>,
69}
70
71pub(crate) fn default_gpu_count() -> u32 {
72    1
73}
74
75#[derive(Debug, Clone, Serialize, Deserialize)]
76pub struct ObservabilityConfig {
77    pub otlp_endpoint: Option<String>,
78    pub alerts: Option<AlertChannelConfig>,
79}
80
81#[derive(Debug, Clone, Serialize, Deserialize)]
82pub struct AlertChannelConfig {
83    pub webhook: Option<String>,
84    pub email: Option<String>,
85}