The artifact that reaches runtime
A multi-stage build produces distinct stages. COPY --from=build /out/worker /app/worker copies the artifact, not the compiler’s entire environment. To modify the image, change the source or Dockerfile, build the intended final stage, and publish an image identity that the target environment can retrieve.
A build with --target build stops at the intermediate stage and may not represent the production image. Build success does not demonstrate that the executable finds its interpreter, libraries, certificates, or configuration files in the final stage.
Check architecture, user, and permissions too. Use the accepted artifact’s digest in the manifest; a mutable tag can identify different content later.
One replica per eligible node
A Deployment manages a replica count; it does not promise one replica on every node. For a collector that must follow each node labelled telemetry=enabled, use a DaemonSet with that selection. Newly eligible nodes join the desired set, and nodes that stop matching leave it.
Selection does not remove scheduling conditions: check taints, tolerations, capacity, and affinity rules. A toleration permits consideration of a node with a particular taint; it neither selects the node nor proves capacity. Compare desiredNumberScheduled, currentNumberScheduled, numberReady, and Pod events. Total cluster node count is not, by itself, the correct denominator.
Finite preparation or a supporting service
A regular init container prepares something and exits successfully before the next one. A process that waits forever in that position prevents the application from starting. A native sidecar is an initContainers entry with restartPolicy: Always at container level.
Kubelet advances to the next init when the sidecar becomes started: if a startupProbe exists, it waits for success; otherwise a running process is enough. This sequence does not mean every business dependency is available. Define a startup check that represents the required preparation.
A helper placed only under containers does not automatically receive these ordering rules.
Readiness and completion are different signals
A readinessProbe on a native sidecar contributes to the Pod Ready condition. Failed readiness can remove that Pod from ready endpoints without restarting the application. In a Job, a native sidecar still running does not prevent completion after the main work finishes; an endless helper under containers can prevent all application containers from finishing.
During Pod termination, native sidecars terminate after the main containers, in reverse declaration order. This supplies a sequence, not a guarantee that all logs are delivered: the termination deadline remains bounded. Important data needs durable acknowledgement and reconciliation.
Share data through an explicit contract
Containers in one Pod share networking, but each keeps its image filesystem. To pass files, declare a volume and mount it in both containers; paths can differ if they refer to the same volume. emptyDir serves temporary data during the Pod lifetime.
Restarting a container is not replacing the Pod. If the application must recover a result after replacement, choose suitable persistence and define how a complete result differs from a partly written file. A sidecar does not create that protocol.
If a collector only exports disposable telemetry, document how that differs from business receipts.
Read the manifest before choosing recovery
The fragment below represents part of a PodSpec, not a standalone lab. Images and commands are illustrative application names. The sidecar starts first and its startupProbe gates progression to the next preparation step; its readinessProbe later contributes to Pod readiness.
If preparation never starts, examine sidecar state and startupProbe before increasing the application timeout. If the application runs but the Pod stays unready, check each readinessProbe. If files are missing, compare volume names and mounts.
This separates startup, readiness, and data, enabling a focused correction.
initContainers:
- name: collector
image: registry.example/collector:reviewed
restartPolicy: Always
startupProbe:
exec:
command: ["/collector-check", "started"]
readinessProbe:
exec:
command: ["/collector-check", "ready"]
volumeMounts:
- name: exchange
mountPath: /input
- name: prepare
image: registry.example/prepare:reviewed
volumeMounts:
- name: exchange
mountPath: /out
containers:
- name: application
image: registry.example/application:reviewed
volumeMounts:
- name: exchange
mountPath: /work
volumes:
- name: exchange
emptyDir: {}An export Job finishes its main work but keeps an endless collector under containers. The team moves the collector to initContainers without other changes, and the work stops starting. The decision needs native-sidecar rules, a meaningful startupProbe, and a file-delivery contract; moving a YAML line does not demonstrate recovery.
Common pitfalls
Confusing one replica per node with a fixed replica count; using a regular init for an endless service; treating readiness as business completion.
Related topics: Workloads and configuration · Observability and security
Choose the controller by the unit of work and each container by its lifecycle. Confirm the final image, sequence, readiness, and persistence separately.
References
- Sidecar containers · Kubernetes v1.37 documentation; targeted passages read 2026-10-23
- DaemonSet · Kubernetes v1.37 documentation; targeted passages read 2026-10-23
- Multi-stage container builds · Docker documentation consulted 2026-10-02
- Volumes · Kubernetes v1.37 documentation; main site consulted 2026-10-02