Safety

aether-deploy

Kubernetes deployment, autoscaling, and multi-region topology

The aether-deploy crate provides deployment infrastructure contracts for Aether, including Kubernetes resource definitions, autoscaling policies, health probes, failover strategies, and multi-region topology configuration.

Overview

Aether's server infrastructure is designed for Kubernetes-native deployment. This crate defines:

  • Deployment manifests with resource requirements, PVC configuration, and workload types.
  • Autoscaling with HPA profiles and custom scaling decisions.
  • Health probes for liveness, readiness, and startup checks.
  • Failover policies for database and service recovery.
  • Multi-region topology with datacenter catalogs and region-aware routing.
  • Affinity rules for pod placement optimization.

Key Types

WorldServerAutoscaler

Manages horizontal pod autoscaling for world server instances.

use aether_deploy::{WorldServerAutoscaler, AutoscalePolicy, HpaProfile};

let policy = AutoscalePolicy {
    min_replicas: 2,
    max_replicas: 50,
    target_cpu_percent: 70,
    scale_up_cooldown_seconds: 60,
    scale_down_cooldown_seconds: 300,
};
let autoscaler = WorldServerAutoscaler::new(policy);

DeploymentConfig

Defines the Kubernetes deployment manifest for a workload.

use aether_deploy::{DeploymentConfig, ResourceRequirements, WorkloadKind, PvcConfig};

let config = DeploymentConfig {
    kind: WorkloadKind::WorldServer,
    resources: ResourceRequirements {
        cpu_request: "500m".into(),
        cpu_limit: "2000m".into(),
        memory_request: "1Gi".into(),
        memory_limit: "4Gi".into(),
    },
    replicas: 3,
};

ProbeConfig

Configures health probes for Kubernetes liveness, readiness, and startup checks.

use aether_deploy::ProbeConfig;

let probe = ProbeConfig {
    path: "/healthz".into(),
    port: 8080,
    initial_delay_seconds: 10,
    period_seconds: 15,
    failure_threshold: 3,
};

DeploymentTopology

Describes the multi-region deployment layout with datacenters and region mappings.

use aether_deploy::{DeploymentTopology, Region, Datacenter, EnvType};

let topology = DeploymentTopology {
    regions: vec![
        Region {
            name: "us-east".into(),
            datacenters: vec![Datacenter {
                name: "us-east-1a".into(),
                env: EnvType::Production,
            }],
        },
    ],
};

ScalingDecision

Represents a scaling action decided by the autoscaler.

use aether_deploy::{ScalingDecision, ScalingAction, ScalingConfig};

let config = ScalingConfig {
    scale_up_threshold: 0.8,
    scale_down_threshold: 0.3,
    evaluation_window_seconds: 120,
};
let decision: ScalingDecision = autoscaler.evaluate(&metrics, &config);

DatabaseFailoverPolicy

Defines failover behavior for database backends.

use aether_deploy::{DatabaseFailoverPolicy, PatroniConfig};

let policy = DatabaseFailoverPolicy {
    auto_failover: true,
    patroni: Some(PatroniConfig {
        ttl: 30,
        loop_wait: 10,
        retry_timeout: 10,
    }),
};

RegionRoutingConfig

Controls how traffic is routed between regions.

use aether_deploy::{RegionRoutingConfig, RegionEndpoint, RoutingDecision};

let config = RegionRoutingConfig {
    endpoints: vec![
        RegionEndpoint { region: "us-east".into(), weight: 70 },
        RegionEndpoint { region: "eu-west".into(), weight: 30 },
    ],
    failover_enabled: true,
};

Usage Examples

Complete Deployment Spec

use aether_deploy::{
    DeploymentConfig, WorkloadKind, ResourceRequirements,
    ProbeConfig, AutoscalePolicy, TopologyConfig, AffinityRule,
};

let deployment = DeploymentConfig {
    kind: WorkloadKind::WorldServer,
    resources: ResourceRequirements {
        cpu_request: "1000m".into(),
        cpu_limit: "4000m".into(),
        memory_request: "2Gi".into(),
        memory_limit: "8Gi".into(),
    },
    replicas: 5,
};

let topology = TopologyConfig {
    affinity: vec![AffinityRule::PreferSameZone],
};