How do you specify environment variables in a Pod manifest?

  1. Both env and envFrom fields ✓
  2. Using the env field in spec.containers
  3. Using the environment field in metadata
  4. Using the envFrom field in spec.containers

Correct answer: Both env and envFrom fields

Option A is correct because Kubernetes supports two complementary approaches for injecting environment variables into containers: the `env` field allows you to define individual key-value pairs directly or source them from ConfigMaps and Secrets, while the `envFrom` field allows bulk import of all keys from a ConfigMap or Secret, and both fields coexist under `spec.containers`. Option B is only partially correct because it omits `envFrom`, which is also a valid and commonly used mechanism. Option C is wrong because there is no `environment` field in the Pod manifest's `metadata` section; metadata holds labels, annotations, and names, not runtime configuration. Option D is only partially correct because it omits the `env` field, which is equally valid for setting environment variables.

Topic: · kubernetes, pod manifest, environment variables, configmap

Practice Certified Kubernetes App Developer (CKAD) Questions Free