pub struct Container {Show 18 fields
pub id: String,
pub links: Vec<ResourceRef>,
pub ports: Vec<ContainerPort>,
pub cluster: Option<String>,
pub code: ContainerCode,
pub cpu: ResourceSpec,
pub memory: ResourceSpec,
pub gpu: Option<ContainerGpuSpec>,
pub ephemeral_storage: Option<String>,
pub persistent_storage: Option<PersistentStorage>,
pub replicas: Option<u32>,
pub autoscaling: Option<ContainerAutoscaling>,
pub stateful: bool,
pub environment: HashMap<String, String>,
pub pool: Option<String>,
pub permissions: String,
pub health_check: Option<HealthCheck>,
pub command: Option<Vec<String>>,
}Expand description
Container resource for running long-running container workloads.
A Container defines a deployable unit that runs on a ContainerCluster. Horizon handles scheduling replicas across machines, autoscaling based on various metrics, and service discovery.
§Example
use alien_core::{Container, ContainerCode, ResourceSpec, ContainerAutoscaling, ContainerPort, ExposeProtocol};
let container = Container::new("api".to_string())
.cluster("compute".to_string())
.code(ContainerCode::Image {
image: "myapp:latest".to_string(),
})
.cpu(ResourceSpec { min: "0.5".to_string(), desired: "1".to_string() })
.memory(ResourceSpec { min: "512Mi".to_string(), desired: "1Gi".to_string() })
.port(8080)
.expose_port(8080, ExposeProtocol::Http)
.autoscaling(ContainerAutoscaling {
min: 2,
desired: 3,
max: 10,
target_cpu_percent: Some(70.0),
target_memory_percent: None,
target_http_in_flight_per_replica: Some(100),
max_http_p95_latency_ms: None,
})
.permissions("container-execution".to_string())
.build();Fields§
§id: StringUnique identifier for the container. Must be DNS-compatible: lowercase alphanumeric with hyphens.
links: Vec<ResourceRef>Resource links (dependencies)
ports: Vec<ContainerPort>Container ports to expose (at least one required)
cluster: Option<String>ContainerCluster resource ID that this container runs on. If None, will be auto-assigned by ContainerClusterMutation at deployment time.
code: ContainerCodeContainer code (image or source)
cpu: ResourceSpecCPU resource requirements
memory: ResourceSpecMemory resource requirements (must use Ki/Mi/Gi/Ti suffix)
gpu: Option<ContainerGpuSpec>GPU requirements (optional)
ephemeral_storage: Option<String>Ephemeral storage requirement (e.g., “10Gi”)
persistent_storage: Option<PersistentStorage>Persistent storage configuration (only for stateful containers)
replicas: Option<u32>Fixed replica count (for stateful containers or stateless without autoscaling)
autoscaling: Option<ContainerAutoscaling>Autoscaling configuration (only for stateless containers)
stateful: boolWhether container is stateful (gets stable ordinals, optional persistent volumes)
environment: HashMap<String, String>Environment variables
pool: Option<String>Capacity group to run on (must exist in the cluster) If not specified, containers are scheduled to any available group.
permissions: StringPermission profile name
health_check: Option<HealthCheck>Health check configuration
command: Option<Vec<String>>Command to override image default
Implementations§
Source§impl Container
impl Container
Sourcepub fn new(id: String) -> ContainerBuilder
pub fn new(id: String) -> ContainerBuilder
Create an instance of Container using the builder syntax
Source§impl Container
impl Container
Sourcepub const RESOURCE_TYPE: ResourceType
pub const RESOURCE_TYPE: ResourceType
The resource type identifier for Container
Sourcepub fn get_permissions(&self) -> &str
pub fn get_permissions(&self) -> &str
Returns the permission profile name for this container.
Sourcepub fn is_stateless(&self) -> bool
pub fn is_stateless(&self) -> bool
Returns true if this container is stateless (not stateful).