KCNA · Question #2
How to load and generate data required before the Pod startup?
The correct answer is A. Use an init container with shared file storage.. Init containers are designed to run to completion before application containers start, making them ideal for pre-populating shared storage with required data.
Question
How to load and generate data required before the Pod startup?
Options
- AUse an init container with shared file storage.
- BUse a PVC volume.
- CUse a sidecar container with shared volume.
- DUse another pod with a PVC.
How the community answered
(46 responses)- A87% (40)
- B7% (3)
- C2% (1)
- D4% (2)
Why each option
Init containers are designed to run to completion before application containers start, making them ideal for pre-populating shared storage with required data.
Init containers run and complete successfully before any application containers in a Pod start, making them perfect for pre-initialization tasks like loading data, which can then be shared with the main application containers via a shared volume.
A PVC (Persistent Volume Claim) provides persistent storage for a Pod but doesn't inherently define how data is loaded into it before application startup, just that it's available.
A sidecar container runs alongside the main application container, not before it, so it cannot ensure data is present before the main application starts.
Using another Pod with a PVC would run independently and wouldn't directly ensure data is loaded into the *current* Pod's volume before its startup, as init containers do.
Concept tested: Kubernetes Init Containers for pre-startup tasks
Source: https://kubernetes.io/docs/concepts/workloads/pods/init-containers/
Topics
Community Discussion
No community discussion yet for this question.