What is the main purpose of using an init container in a Kubernetes Pod?
Think about tasks that must finish before the main app runs.
Init containers run before app containers to prepare the environment, such as setting up files or waiting for services.
Given the following kubectl get pod mypod -o json snippet showing init container status, what is the state of the init container?
{
"status": {
"initContainerStatuses": [
{
"name": "init-setup",
"state": {
"terminated": {
"exitCode": 0,
"reason": "Completed"
}
}
}
]
}
}Look at the exitCode and reason fields.
The init container terminated with exit code 0 and reason 'Completed', meaning it finished successfully.
Which YAML snippet correctly defines an init container that copies files from a shared volume before the main container starts?
Check the placement of initContainers and volume mounts.
Option A correctly places the init container under initContainers, uses a shell command to copy files, and mounts the shared volume in both containers.
You have an init container that never completes and blocks the main container from starting. Which of the following is the most likely cause?
Think about what can cause a container to hang during startup.
If the init container command waits indefinitely (e.g., for input or a service), it will block the pod from progressing.
Consider a Pod with three init containers named init1, init2, and init3. Which statement correctly describes their execution order?
Think about how Kubernetes ensures setup tasks complete before the app runs.
Init containers run one after another in the order they appear in the Pod spec. Each must finish successfully before the next starts.