oxirs-stream 0.2.4

Real-time streaming support with Kafka/NATS/MQTT/OPC-UA I/O, RDF Patch, and SPARQL Update delta
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
//! Cloud-Native Manager Implementation

use anyhow::{anyhow, Result};
use chrono::{DateTime, Duration as ChronoDuration, Utc};
use serde::{Deserialize, Serialize};
use std::collections::{HashMap, BTreeMap};
use std::sync::Arc;
use std::time::{Duration, Instant};
use tokio::sync::{Mutex, RwLock};
use tracing::{debug, error, info, warn};
use uuid::Uuid;

use super::config::*;
use super::kubernetes::*;
use super::service_mesh::*;
use super::auto_scaling::*;
use super::observability::*;
use super::multi_cloud::*;
use super::gitops::*;
pub struct CloudNativeManager {
    config: CloudNativeConfig,
    kubernetes_client: Arc<dyn KubernetesClient>,
    service_mesh_client: Arc<dyn ServiceMeshClient>,
    metrics: Arc<RwLock<CloudNativeMetrics>>,
}

impl CloudNativeManager {
    /// Create a new cloud-native manager
    pub fn new(
        config: CloudNativeConfig,
        kubernetes_client: Arc<dyn KubernetesClient>,
        service_mesh_client: Arc<dyn ServiceMeshClient>,
    ) -> Self {
        Self {
            config,
            kubernetes_client,
            service_mesh_client,
            metrics: Arc::new(RwLock::new(CloudNativeMetrics::default())),
        }
    }

    /// Deploy OxiRS resources to Kubernetes
    pub async fn deploy(&self) -> Result<()> {
        info!("Starting deployment of OxiRS resources");

        // Create namespace
        self.create_namespace().await?;

        // Deploy CRDs
        self.deploy_crds().await?;

        // Deploy operator
        if self.config.kubernetes.operator.enabled {
            self.deploy_operator().await?;
        }

        // Configure service mesh
        if self.config.service_mesh.enabled {
            self.configure_service_mesh().await?;
        }

        // Setup monitoring
        if self.config.observability.monitoring.prometheus.enabled {
            self.setup_monitoring().await?;
        }

        // Setup auto-scaling
        if self.config.auto_scaling.enabled {
            self.setup_auto_scaling().await?;
        }

        info!("Successfully deployed OxiRS resources");
        Ok(())
    }

    /// Create namespace
    async fn create_namespace(&self) -> Result<()> {
        let namespace = KubernetesResource::Namespace {
            metadata: ObjectMetadata {
                name: self.config.kubernetes.namespace.clone(),
                namespace: None,
                labels: BTreeMap::from([
                    ("app".to_string(), "oxirs".to_string()),
                    ("managed-by".to_string(), "oxirs-operator".to_string()),
                ]),
                annotations: BTreeMap::new(),
            },
        };

        self.kubernetes_client.apply_resource(namespace).await?;
        Ok(())
    }

    /// Deploy CRDs
    async fn deploy_crds(&self) -> Result<()> {
        for crd in &self.config.kubernetes.crds {
            let resource = KubernetesResource::CustomResourceDefinition(crd.clone());
            self.kubernetes_client.apply_resource(resource).await?;
        }
        Ok(())
    }

    /// Deploy operator
    async fn deploy_operator(&self) -> Result<()> {
        let operator_deployment = self.create_operator_deployment();
        self.kubernetes_client.apply_resource(operator_deployment).await?;
        Ok(())
    }

    /// Create operator deployment
    fn create_operator_deployment(&self) -> KubernetesResource {
        KubernetesResource::Deployment {
            metadata: ObjectMetadata {
                name: "oxirs-operator".to_string(),
                namespace: Some(self.config.kubernetes.namespace.clone()),
                labels: BTreeMap::from([
                    ("app".to_string(), "oxirs-operator".to_string()),
                ]),
                annotations: BTreeMap::new(),
            },
            spec: DeploymentSpec {
                replicas: 1,
                selector: LabelSelector {
                    match_labels: BTreeMap::from([
                        ("app".to_string(), "oxirs-operator".to_string()),
                    ]),
                },
                template: PodTemplateSpec {
                    metadata: ObjectMetadata {
                        name: "oxirs-operator".to_string(),
                        namespace: Some(self.config.kubernetes.namespace.clone()),
                        labels: BTreeMap::from([
                            ("app".to_string(), "oxirs-operator".to_string()),
                        ]),
                        annotations: BTreeMap::new(),
                    },
                    spec: PodSpec {
                        containers: vec![
                            Container {
                                name: "operator".to_string(),
                                image: self.config.kubernetes.operator.image.clone(),
                                resources: Some(ResourceRequirements {
                                    cpu: "100m".to_string(),
                                    memory: "128Mi".to_string(),
                                }),
                                env: vec![
                                    EnvVar {
                                        name: "NAMESPACE".to_string(),
                                        value: self.config.kubernetes.namespace.clone(),
                                    },
                                    EnvVar {
                                        name: "RECONCILE_INTERVAL".to_string(),
                                        value: format!("{}s", self.config.kubernetes.operator.reconcile_interval.as_secs()),
                                    },
                                ],
                                ports: vec![
                                    ContainerPort {
                                        name: "metrics".to_string(),
                                        container_port: 8080,
                                        protocol: "TCP".to_string(),
                                    },
                                ],
                            },
                        ],
                        service_account: Some("oxirs-operator".to_string()),
                    },
                },
            },
        }
    }

    /// Configure service mesh
    async fn configure_service_mesh(&self) -> Result<()> {
        match self.config.service_mesh.provider {
            ServiceMeshProvider::Istio => self.configure_istio().await?,
            ServiceMeshProvider::Linkerd => self.configure_linkerd().await?,
            ServiceMeshProvider::ConsulConnect => self.configure_consul_connect().await?,
            _ => {
                warn!("Service mesh provider {:?} not implemented", self.config.service_mesh.provider);
            }
        }
        Ok(())
    }

    /// Configure Istio
    async fn configure_istio(&self) -> Result<()> {
        // Enable sidecar injection
        self.service_mesh_client.enable_sidecar_injection(&self.config.kubernetes.namespace).await?;

        // Configure destination rules
        self.service_mesh_client.apply_destination_rules(&self.config.service_mesh.traffic_management).await?;

        // Configure virtual services
        self.service_mesh_client.apply_virtual_services(&self.config.service_mesh.traffic_management).await?;

        // Configure authorization policies
        self.service_mesh_client.apply_authorization_policies(&self.config.service_mesh.security_policies).await?;

        Ok(())
    }

    /// Configure Linkerd
    async fn configure_linkerd(&self) -> Result<()> {
        // Implement Linkerd configuration
        warn!("Linkerd configuration not yet implemented");
        Ok(())
    }

    /// Configure Consul Connect
    async fn configure_consul_connect(&self) -> Result<()> {
        // Implement Consul Connect configuration
        warn!("Consul Connect configuration not yet implemented");
        Ok(())
    }

    /// Setup monitoring
    async fn setup_monitoring(&self) -> Result<()> {
        // Deploy Prometheus
        self.deploy_prometheus().await?;

        // Deploy service monitors
        self.deploy_service_monitors().await?;

        // Deploy Grafana
        if self.config.observability.dashboards.grafana.enabled {
            self.deploy_grafana().await?;
        }

        Ok(())
    }

    /// Deploy Prometheus
    async fn deploy_prometheus(&self) -> Result<()> {
        let prometheus = KubernetesResource::StatefulSet {
            metadata: ObjectMetadata {
                name: "prometheus".to_string(),
                namespace: Some(self.config.kubernetes.namespace.clone()),
                labels: BTreeMap::from([
                    ("app".to_string(), "prometheus".to_string()),
                ]),
                annotations: BTreeMap::new(),
            },
            spec: StatefulSetSpec {
                replicas: 1,
                selector: LabelSelector {
                    match_labels: BTreeMap::from([
                        ("app".to_string(), "prometheus".to_string()),
                    ]),
                },
                template: PodTemplateSpec {
                    metadata: ObjectMetadata {
                        name: "prometheus".to_string(),
                        namespace: Some(self.config.kubernetes.namespace.clone()),
                        labels: BTreeMap::from([
                            ("app".to_string(), "prometheus".to_string()),
                        ]),
                        annotations: BTreeMap::new(),
                    },
                    spec: PodSpec {
                        containers: vec![
                            Container {
                                name: "prometheus".to_string(),
                                image: "prom/prometheus:latest".to_string(),
                                resources: Some(self.config.observability.monitoring.prometheus.resources.clone()),
                                env: vec![],
                                ports: vec![
                                    ContainerPort {
                                        name: "web".to_string(),
                                        container_port: 9090,
                                        protocol: "TCP".to_string(),
                                    },
                                ],
                            },
                        ],
                        service_account: Some("prometheus".to_string()),
                    },
                },
                volume_claim_templates: vec![
                    VolumeClaimTemplate {
                        metadata: ObjectMetadata {
                            name: "prometheus-storage".to_string(),
                            namespace: Some(self.config.kubernetes.namespace.clone()),
                            labels: BTreeMap::new(),
                            annotations: BTreeMap::new(),
                        },
                        spec: VolumeClaimSpec {
                            access_modes: vec!["ReadWriteOnce".to_string()],
                            resources: ResourceRequirements {
                                cpu: "".to_string(),
                                memory: self.config.observability.monitoring.prometheus.storage_size.clone(),
                            },
                        },
                    },
                ],
            },
        };

        self.kubernetes_client.apply_resource(prometheus).await?;
        Ok(())
    }

    /// Deploy service monitors
    async fn deploy_service_monitors(&self) -> Result<()> {
        for monitor in &self.config.observability.monitoring.service_monitors {
            let service_monitor = KubernetesResource::ServiceMonitor(monitor.clone());
            self.kubernetes_client.apply_resource(service_monitor).await?;
        }
        Ok(())
    }

    /// Deploy Grafana
    async fn deploy_grafana(&self) -> Result<()> {
        let grafana = KubernetesResource::Deployment {
            metadata: ObjectMetadata {
                name: "grafana".to_string(),
                namespace: Some(self.config.kubernetes.namespace.clone()),
                labels: BTreeMap::from([
                    ("app".to_string(), "grafana".to_string()),
                ]),
                annotations: BTreeMap::new(),
            },
            spec: DeploymentSpec {
                replicas: 1,
                selector: LabelSelector {
                    match_labels: BTreeMap::from([
                        ("app".to_string(), "grafana".to_string()),
                    ]),
                },
                template: PodTemplateSpec {
                    metadata: ObjectMetadata {
                        name: "grafana".to_string(),
                        namespace: Some(self.config.kubernetes.namespace.clone()),
                        labels: BTreeMap::from([
                            ("app".to_string(), "grafana".to_string()),
                        ]),
                        annotations: BTreeMap::new(),
                    },
                    spec: PodSpec {
                        containers: vec![
                            Container {
                                name: "grafana".to_string(),
                                image: "grafana/grafana:latest".to_string(),
                                resources: Some(self.config.observability.dashboards.grafana.resources.clone()),
                                env: vec![
                                    EnvVar {
                                        name: "GF_SECURITY_ADMIN_USER".to_string(),
                                        value: self.config.observability.dashboards.grafana.admin_user.clone(),
                                    },
                                    EnvVar {
                                        name: "GF_SECURITY_ADMIN_PASSWORD".to_string(),
                                        value: self.config.observability.dashboards.grafana.admin_password.clone(),
                                    },
                                ],
                                ports: vec![
                                    ContainerPort {
                                        name: "web".to_string(),
                                        container_port: 3000,
                                        protocol: "TCP".to_string(),
                                    },
                                ],
                            },
                        ],
                        service_account: Some("grafana".to_string()),
                    },
                },
            },
        };

        self.kubernetes_client.apply_resource(grafana).await?;
        Ok(())
    }

    /// Setup auto-scaling
    async fn setup_auto_scaling(&self) -> Result<()> {
        if self.config.auto_scaling.hpa.enabled {
            self.setup_hpa().await?;
        }

        if self.config.auto_scaling.vpa.enabled {
            self.setup_vpa().await?;
        }

        Ok(())
    }

    /// Setup HPA
    async fn setup_hpa(&self) -> Result<()> {
        let hpa = KubernetesResource::HorizontalPodAutoscaler {
            metadata: ObjectMetadata {
                name: "oxirs-stream-hpa".to_string(),
                namespace: Some(self.config.kubernetes.namespace.clone()),
                labels: BTreeMap::from([
                    ("app".to_string(), "oxirs-stream".to_string()),
                ]),
                annotations: BTreeMap::new(),
            },
            spec: HPASpec {
                scale_target_ref: ScaleTargetRef {
                    api_version: "apps/v1".to_string(),
                    kind: "Deployment".to_string(),
                    name: "oxirs-stream".to_string(),
                },
                min_replicas: Some(self.config.auto_scaling.hpa.min_replicas),
                max_replicas: self.config.auto_scaling.hpa.max_replicas,
                target_cpu_utilization_percentage: Some(self.config.auto_scaling.hpa.target_cpu_utilization as i32),
                metrics: vec![
                    MetricSpec {
                        metric_type: "Resource".to_string(),
                        resource: Some(ResourceMetricSource {
                            name: "cpu".to_string(),
                            target: MetricTarget {
                                target_type: "Utilization".to_string(),
                                average_utilization: Some(self.config.auto_scaling.hpa.target_cpu_utilization as i32),
                            },
                        }),
                    },
                    MetricSpec {
                        metric_type: "Resource".to_string(),
                        resource: Some(ResourceMetricSource {
                            name: "memory".to_string(),
                            target: MetricTarget {
                                target_type: "Utilization".to_string(),
                                average_utilization: Some(self.config.auto_scaling.hpa.target_memory_utilization as i32),
                            },
                        }),
                    },
                ],
            },
        };

        self.kubernetes_client.apply_resource(hpa).await?;
        Ok(())
    }

    /// Setup VPA
    async fn setup_vpa(&self) -> Result<()> {
        warn!("VPA setup not yet implemented");
        Ok(())
    }

    /// Get metrics
    pub async fn get_metrics(&self) -> CloudNativeMetrics {
        self.metrics.read().await.clone()
    }
}

/// Kubernetes client trait
#[async_trait::async_trait]
pub trait KubernetesClient: Send + Sync {
    async fn apply_resource(&self, resource: KubernetesResource) -> Result<()>;
    async fn delete_resource(&self, resource: KubernetesResource) -> Result<()>;
    async fn get_resource(&self, resource_type: &str, name: &str, namespace: &str) -> Result<Option<KubernetesResource>>;
    async fn list_resources(&self, resource_type: &str, namespace: &str) -> Result<Vec<KubernetesResource>>;
}

/// Service mesh client trait
#[async_trait::async_trait]
pub trait ServiceMeshClient: Send + Sync {
    async fn enable_sidecar_injection(&self, namespace: &str) -> Result<()>;
    async fn apply_destination_rules(&self, config: &TrafficManagementConfig) -> Result<()>;
    async fn apply_virtual_services(&self, config: &TrafficManagementConfig) -> Result<()>;
    async fn apply_authorization_policies(&self, config: &SecurityPolicyConfig) -> Result<()>;
}

/// Kubernetes resource
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum KubernetesResource {
    Namespace {
        metadata: ObjectMetadata,
    },
    CustomResourceDefinition(CustomResourceDefinition),
    Deployment {
        metadata: ObjectMetadata,
        spec: DeploymentSpec,
    },
    StatefulSet {
        metadata: ObjectMetadata,
        spec: StatefulSetSpec,
    },
    Service {
        metadata: ObjectMetadata,
        spec: ServiceSpec,
    },
    ConfigMap {
        metadata: ObjectMetadata,
        data: BTreeMap<String, String>,
    },
    Secret {
        metadata: ObjectMetadata,
        data: BTreeMap<String, Vec<u8>>,
    },
    ServiceMonitor(ServiceMonitor),
    HorizontalPodAutoscaler {
        metadata: ObjectMetadata,
        spec: HPASpec,
    },
}

/// Deployment specification
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DeploymentSpec {
    pub replicas: u32,
    pub selector: LabelSelector,
    pub template: PodTemplateSpec,
}

/// StatefulSet specification
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StatefulSetSpec {
    pub replicas: u32,
    pub selector: LabelSelector,
    pub template: PodTemplateSpec,
    pub volume_claim_templates: Vec<VolumeClaimTemplate>,
}

/// Pod template specification
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PodTemplateSpec {
    pub metadata: ObjectMetadata,
    pub spec: PodSpec,
}

/// Pod specification
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PodSpec {
    pub containers: Vec<Container>,
    pub service_account: Option<String>,
}

/// Container specification
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Container {
    pub name: String,
    pub image: String,
    pub resources: Option<ResourceRequirements>,
    pub env: Vec<EnvVar>,
    pub ports: Vec<ContainerPort>,
}

/// Environment variable
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EnvVar {
    pub name: String,
    pub value: String,
}

/// Container port
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ContainerPort {
    pub name: String,
    pub container_port: u16,
    pub protocol: String,
}

/// Service specification
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ServiceSpec {
    pub selector: LabelSelector,
    pub ports: Vec<ServicePort>,
    pub service_type: String,
}

/// Service port
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ServicePort {
    pub name: String,
    pub port: u16,
    pub target_port: u16,
    pub protocol: String,
}

/// Volume claim template
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VolumeClaimTemplate {
    pub metadata: ObjectMetadata,
    pub spec: VolumeClaimSpec,
}

/// Volume claim specification
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VolumeClaimSpec {
    pub access_modes: Vec<String>,
    pub resources: ResourceRequirements,
}

/// HPA specification
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct HPASpec {
    pub scale_target_ref: ScaleTargetRef,
    pub min_replicas: Option<u32>,
    pub max_replicas: u32,
    pub target_cpu_utilization_percentage: Option<i32>,
    pub metrics: Vec<MetricSpec>,
}

/// Scale target reference
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ScaleTargetRef {
    pub api_version: String,
    pub kind: String,
    pub name: String,
}

/// Metric specification
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MetricSpec {
    #[serde(rename = "type")]
    pub metric_type: String,
    pub resource: Option<ResourceMetricSource>,
}

/// Resource metric source
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ResourceMetricSource {
    pub name: String,
    pub target: MetricTarget,
}

/// Metric target
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MetricTarget {
    #[serde(rename = "type")]
    pub target_type: String,
    pub average_utilization: Option<i32>,
}

/// Cloud-native metrics
#[derive(Debug, Clone, Default)]
pub struct CloudNativeMetrics {
    pub deployments_created: u64,
    pub deployments_updated: u64,
    pub deployments_deleted: u64,
    pub pods_running: u64,
    pub service_mesh_enabled: bool,
    pub auto_scaling_events: u64,
    pub last_deployment_time: Option<DateTime<Utc>>,
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_cloud_native_config_defaults() {
        let config = CloudNativeConfig::default();
        assert!(config.kubernetes.enabled);
        assert_eq!(config.kubernetes.namespace, "oxirs");
        assert!(config.service_mesh.enabled);
        assert_eq!(config.service_mesh.provider, ServiceMeshProvider::Istio);
        assert!(config.auto_scaling.enabled);
    }

    #[test]
    fn test_custom_resource_definition_creation() {
        let crd = CustomResourceDefinition::stream_processor();
        assert_eq!(crd.kind, "CustomResourceDefinition");
        assert_eq!(crd.spec.group, "oxirs.io");
        assert_eq!(crd.spec.names.kind, "StreamProcessor");
    }

    #[test]
    fn test_kubernetes_config_serialization() {
        let config = KubernetesConfig::default();
        let serialized = serde_json::to_string(&config).unwrap();
        let deserialized: KubernetesConfig = serde_json::from_str(&serialized).unwrap();
        assert_eq!(config.namespace, deserialized.namespace);
        assert_eq!(config.enabled, deserialized.enabled);
    }

    #[test]
    fn test_service_mesh_config() {
        let config = ServiceMeshConfig::default();
        assert!(config.enabled);
        assert!(config.mtls.enabled);
        assert_eq!(config.mtls.mode, MutualTLSMode::Strict);
        assert_eq!(config.traffic_management.load_balancing, LoadBalancingStrategy::RoundRobin);
    }

    #[test]
    fn test_auto_scaling_config() {
        let config = AutoScalingConfig::default();
        assert!(config.enabled);
        assert!(config.hpa.enabled);
        assert_eq!(config.hpa.min_replicas, 2);
        assert_eq!(config.hpa.max_replicas, 100);
        assert_eq!(config.hpa.target_cpu_utilization, 70.0);
    }

    #[test]
    fn test_observability_config() {
        let config = ObservabilityConfig::default();
        assert!(config.monitoring.prometheus.enabled);
        assert!(config.dashboards.grafana.enabled);
        assert_eq!(config.dashboards.grafana.admin_user, "admin");
    }

    #[test]
    fn test_gitops_config() {
        let config = GitOpsConfig::default();
        assert!(config.enabled);
        assert_eq!(config.provider, GitOpsProvider::ArgoCD);
        assert!(config.sync.auto_sync);
        assert!(config.sync.prune);
        assert!(config.sync.self_heal);
    }
}