Skip to main content

ServiceSpec

Struct ServiceSpec 

Source
pub struct ServiceSpec {
Show 49 fields pub rtype: ResourceType, pub schedule: Option<String>, pub image: ImageSpec, pub resources: ResourcesSpec, pub env: HashMap<String, String>, pub command: CommandSpec, pub network: ServiceNetworkSpec, pub endpoints: Vec<EndpointSpec>, pub scale: ScaleSpec, pub depends: Vec<DependsSpec>, pub health: HealthSpec, pub init: InitSpec, pub errors: ErrorsSpec, pub lifecycle: LifecycleSpec, pub devices: Vec<DeviceSpec>, pub storage: Vec<StorageSpec>, pub port_mappings: Vec<PortMapping>, pub capabilities: Vec<String>, pub cap_drop: Vec<String>, pub privileged: bool, pub node_mode: NodeMode, pub node_selector: Option<NodeSelector>, pub platform: Option<TargetPlatform>, pub service_type: ServiceType, pub wasm: Option<WasmConfig>, pub logs: Option<LogsConfig>, pub host_network: bool, pub hostname: Option<String>, pub dns: Vec<String>, pub extra_hosts: Vec<String>, pub restart_policy: Option<ContainerRestartPolicy>, pub labels: HashMap<String, String>, pub user: Option<String>, pub stop_signal: Option<String>, pub stop_grace_period: Option<Duration>, pub sysctls: HashMap<String, String>, pub ulimits: HashMap<String, UlimitSpec>, pub security_opt: Vec<String>, pub pid_mode: Option<String>, pub ipc_mode: Option<String>, pub network_mode: NetworkMode, pub extra_groups: Vec<String>, pub read_only_root_fs: bool, pub init_container: Option<bool>, pub tty: bool, pub stdin_open: bool, pub userns_mode: Option<String>, pub cgroup_parent: Option<String>, pub expose: Vec<String>,
}
Expand description

Per-service specification

Fields§

§rtype: ResourceType

Resource type (service, job, cron)

§schedule: Option<String>

Cron schedule expression (only for rtype: cron) Uses 7-field cron syntax: “sec min hour day-of-month month day-of-week year” Examples:

  • “0 0 0 * * * *” (daily at midnight)
  • “0 */5 * * * * *” (every 5 minutes)
  • “0 0 12 * * MON-FRI *” (weekdays at noon)
§image: ImageSpec

Container image specification

§resources: ResourcesSpec

Resource limits

§env: HashMap<String, String>

Environment variables for the service

Values can be:

  • Plain strings: "value"
  • Host env refs: $E:VAR_NAME
  • Secret refs: $S:secret-name or $S:@service/secret-name
§command: CommandSpec

Command override (entrypoint, args, workdir)

§network: ServiceNetworkSpec

Network configuration

§endpoints: Vec<EndpointSpec>

Endpoint definitions (proxy bindings)

§scale: ScaleSpec

Scaling configuration

§depends: Vec<DependsSpec>

Dependency specifications

§health: HealthSpec

Health check configuration

§init: InitSpec

Init actions (pre-start lifecycle steps)

§errors: ErrorsSpec

Error handling policies

§lifecycle: LifecycleSpec

Container lifecycle policy (e.g., delete-on-exit).

Purely declarative on this type; downstream layers (agent / API / scheduler) read this field to decide whether to clean up the container record after termination.

§devices: Vec<DeviceSpec>

Device passthrough (e.g., /dev/kvm for VMs)

§storage: Vec<StorageSpec>

Storage mounts for the container

§port_mappings: Vec<PortMapping>

Host-to-container port mappings (Docker’s -p host:container/proto).

Each entry publishes a container port on the host. When host_port is None (or zero), the daemon assigns an ephemeral host port.

§capabilities: Vec<String>

Linux capabilities to add (e.g., SYS_ADMIN, NET_ADMIN).

Also accepts the Docker-compatible alias cap_add on input.

§cap_drop: Vec<String>

Linux capabilities to drop (Docker --cap-drop).

§privileged: bool

Run container in privileged mode (all capabilities + all devices)

§node_mode: NodeMode

Node allocation mode (shared, dedicated, exclusive)

§node_selector: Option<NodeSelector>

Node selection constraints (required/preferred labels)

§platform: Option<TargetPlatform>

Target platform for this service. When None (default), the service is eligible to run on any agent regardless of OS/architecture. When Some, the scheduler will only place replicas on agents whose platform matches.

§service_type: ServiceType

Service type (standard, wasm_http, wasm_plugin, etc.)

§wasm: Option<WasmConfig>

WASM configuration (used when service_type is any Wasm* variant) Also accepts the deprecated wasm_http key for backward compatibility.

§logs: Option<LogsConfig>

Log output configuration. If not set, uses platform defaults.

§host_network: bool

Use host networking (container shares host network namespace)

When true, the container will NOT get its own network namespace. This is set programmatically via the --host-network CLI flag, not in YAML specs.

§hostname: Option<String>

Container hostname (maps to Docker’s --hostname).

When set, the container’s /etc/hostname and initial kernel hostname are configured to this value. Ignored when host_network is true (the container inherits the host’s hostname).

§dns: Vec<String>

Additional DNS servers for the container (maps to Docker’s --dns).

Each entry must be a plausible IPv4 or IPv6 address. Forwarded to the container runtime as resolver addresses ahead of the platform defaults. Ignored when host_network is true.

§extra_hosts: Vec<String>

Extra hostname:ip entries appended to /etc/hosts (maps to Docker’s --add-host).

Each entry must be in the form "<hostname>:<ip>". The special literal host-gateway is accepted as the <ip> half (resolved by Docker / bollard to the host-visible gateway address, commonly used with host.docker.internal:host-gateway).

§restart_policy: Option<ContainerRestartPolicy>

Container restart policy (Docker-style).

Controls when the runtime should automatically restart the container after it exits. Maps to Docker’s HostConfig.RestartPolicy. Named ContainerRestartPolicy to avoid colliding with ZLayer’s existing PanicPolicy (which controls post-panic behavior, not runtime-level restarts).

§labels: HashMap<String, String>

Free-form key/value labels attached to the container (Docker --label).

§user: Option<String>

User and group override for the container’s main process (Docker --user uid:gid).

§stop_signal: Option<String>

Signal sent to the container’s main process to request a graceful shutdown (Docker --stop-signal). Accepts e.g. "SIGTERM" or "15".

§stop_grace_period: Option<Duration>

Grace period to wait between the stop signal and a forced kill (Docker --stop-timeout).

§sysctls: HashMap<String, String>

Kernel sysctl overrides (Docker --sysctl).

§ulimits: HashMap<String, UlimitSpec>

Per-process ulimits (Docker --ulimit).

§security_opt: Vec<String>

Security options such as apparmor=..., seccomp=..., no-new-privileges:true (Docker --security-opt).

§pid_mode: Option<String>

PID namespace mode (Docker --pid). Accepts e.g. "host" or "container:<id>".

§ipc_mode: Option<String>

IPC namespace mode (Docker --ipc). Accepts e.g. "host", "shareable", "private", or "container:<id>".

§network_mode: NetworkMode

Network mode (Docker --network). Accepts both the enum-tagged form and the Docker-style strings ("host", "none", "bridge", "bridge:<name>", "container:<id>").

§extra_groups: Vec<String>

Additional groups to add to the container process (Docker --group-add).

§read_only_root_fs: bool

Mount the container’s root filesystem read-only (Docker --read-only).

§init_container: Option<bool>

Run a Docker-supplied init process (PID 1) inside the container (Docker --init). Distinct from ServiceSpec::init which controls ZLayer’s pre-start init actions.

§tty: bool

Allocate a TTY for the container’s main process (Docker --tty, compose tty: true).

§stdin_open: bool

Keep STDIN open even when nothing is attached (Docker --interactive, compose stdin_open: true).

§userns_mode: Option<String>

User namespace mode (Docker --userns). Accepts e.g. "host" or a remap-spec name configured on the daemon.

§cgroup_parent: Option<String>

Cgroup parent path (Docker --cgroup-parent). When set, the runtime places the container under the given cgroup hierarchy.

§expose: Vec<String>

Container ports exposed but not published to the host (compose expose:). Each entry is a port string, optionally port/proto (e.g. "3000", "8080/tcp"). Treated as documentation by the runtime; downstream networking layers may use this list to allow inter-service traffic without publishing to the host.

Trait Implementations§

Source§

impl Clone for ServiceSpec

Source§

fn clone(&self) -> ServiceSpec

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ServiceSpec

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ServiceSpec

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for ServiceSpec

Source§

fn eq(&self, other: &ServiceSpec) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ServiceSpec

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Validate for ServiceSpec

Source§

impl<'v_a> ValidateArgs<'v_a> for ServiceSpec

Source§

impl StructuralPartialEq for ServiceSpec

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromBase64 for T
where T: for<'de> Deserialize<'de>,

Source§

fn from_base64<Input>(raw: &Input) -> Result<T, Error>
where Input: AsRef<[u8]> + ?Sized,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<C> SignWithKey<String> for C
where C: ToBase64,

Source§

impl<T> ToBase64 for T
where T: Serialize,

Source§

fn to_base64(&self) -> Result<Cow<'_, str>, Error>

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,