An application requires a unique identifier per replica, stored in an environment variable. Which Kubernetes resource should be used to inject this identifier into each pod without manual updates?
Trap 1: Deployment with pod anti-affinity to schedule each pod on a…
Anti-affinity doesn't provide unique identifiers.
Trap 2: DaemonSet with a node name environment variable.
DaemonSet pods are per node, not per replica.
Trap 3: Job with a completion index environment variable.
Jobs are for run-to-completion, not long-running services.
- A
Deployment with pod anti-affinity to schedule each pod on a different node.
Why it fails: Anti-affinity doesn't provide unique identifiers.
- B
StatefulSet with an environment variable derived from the pod name.
StatefulSet pods have stable, unique names (e.g., myapp-0).
- C
DaemonSet with a node name environment variable.
Why it fails: DaemonSet pods are per node, not per replica.
- D
Job with a completion index environment variable.
Why it fails: Jobs are for run-to-completion, not long-running services.