Container deployment and health checks
Quick answer
A container deployment packages the compiled application and its runtime requirements. Health signals help the platform decide whether a process should receive traffic or needs recovery.
Build and run with explicit contracts
A multi-stage image separates compiler tools from runtime files. Check target ABI, shared libraries, certificates, non-root permissions and resource limits; pin and review base images and never bake secrets into layers. Liveness indicates whether recovery by restart is needed, readiness whether traffic should be routed, and startup probes allow initialization. During termination stop accepting work, drain within a deadline and coordinate with the platform. This lesson models state; it does not deploy to Kubernetes.
fn health(loop_ok: bool, initialized: bool, draining: bool) -> (bool, bool) { (loop_ok, loop_ok && initialized && !draining)}fn main() { println!("{:?}", health(true, false, false)); println!("{:?}", health(true, true, false)); println!("{:?}", health(true, true, true));}Expected stdout (not executed):
(true, false)(true, true)(true, false)A draining process may still be alive but should no longer advertise readiness.
# In a scratch Linux Cargo application with Cargo.lock committed:cargo +1.85.0 build --release --locked# Replace task_service with your actual binary name.file target/release/task_servicereadelf -d target/release/task_serviceManual terminal step; not executed. Expected behavior (environment dependent):
Release build and ELF information on a supported Linux host with these tools installed.Review needed libraries before selecting the runtime image. This is not a container build.
Common mistake
Do not use dependency outages as an unconditional reason to restart all instances; distinguish readiness from liveness.
Try it yourself
Write a deployment checklist covering image digests, non-root user, resource limits, probes, termination deadline and rollback.
Static examples for Rust 1.85.0, edition 2024. Run them locally in a disposable project; ByteMind execution support and these outputs have not been verified.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Container deployment and health checks — practice quiz
Choose one answer per question. Code examples are predictions; review explanations after attempting them.
A container is draining existing requests during termination. Which probe behavior fits?
Container deployment and health checks — example 1. Read the code; do not execute it for this question. Assume the lesson’s stated setup, compatible dependencies and toolchain, and a fresh disposable directory for file-creating examples. ```rust fn health(loop_ok: bool, initialized: bool, draining: bool) -> (bool, bool) { (loop_ok, loop_ok && initialized && !draining) } fn main() { println!("{:?}", health(true, false, false)); println!("{:?}", health(true, true, false)); println!("{:?}", health(true, true, true)); } ``` What standard output should the program produce if its run succeeds? Ignore Cargo and diagnostic messages.
Container deployment and health checks — example 2. Read the code; do not execute it for this question. Assume the lesson’s stated setup, compatible dependencies and toolchain, and a fresh disposable directory for file-creating examples. ```bash # In a scratch Linux Cargo application with Cargo.lock committed: cargo +1.85.0 build --release --locked # Replace task_service with your actual binary name. file target/release/task_service readelf -d target/release/task_service ``` Which outcome or interpretation best matches this example?