Question 11
Domain 2: Workloads & SchedulingWhich Kubernetes feature allows an init container with `restartPolicy: Always` to run as a native sidecar in a Pod?
Correct answer: A
Explanation
Kubernetes supports native sidecars by letting an init container use `restartPolicy: Always`. This makes the init container run alongside the main containers instead of exiting after initialization, which is why it can function as a sidecar in the Pod.
Why each option is right or wrong
A. Using an init container with `restartPolicy: Always` to define a native sidecar container
Kubernetes added native sidecar support by allowing an init container to be declared with `restartPolicy: Always`, which changes its behavior from a one-shot initializer to a long-lived container that stays running with the Pod. In the Pod API, init containers normally run to completion before app containers start, but this specific restart policy is the feature that makes the init container persist alongside the workload as a sidecar rather than terminate after setup.
B. Using a regular container with `livenessProbe` to keep it running alongside the main container
C. Using a `DaemonSet` to inject a log-collecting container into the Pod
D. Using a `postStart` lifecycle hook on the main container to start the log tailing process