Question 24
Domain 1: Application Design and BuildWhich kubectl approach creates a ConfigMap named "anotherone" with keys var6=val6 and var7=val7, then injects it as environment variables into a new nginx Pod?
Correct answer: A
Explanation
`envFrom` with `configMapRef` imports every key from a ConfigMap into a container’s environment, so `var6=val6` and `var7=val7` become env vars in the nginx Pod. Creating the ConfigMap named `anotherone` first is required because the Pod spec can only reference an existing ConfigMap by name.
Why each option is right or wrong
A. Create the ConfigMap and use envFrom with configMapRef in the Pod spec
Under the Kubernetes API, a ConfigMap is created first with `kubectl create configmap anotherone --from-literal=var6=val6 --from-literal=var7=val7`, which stores exactly those two key/value pairs under the name `anotherone`. In the Pod manifest, the container can then import that data via `envFrom: - configMapRef: name: anotherone`, which is the supported mechanism for projecting all keys from an existing ConfigMap into the container’s environment at creation time.
B. Create the ConfigMap and mount it as a volume at /etc/config in the Pod spec
C. Create a Secret named anotherone and use env.valueFrom.secretKeyRef for each variable
D. Set container args to source the ConfigMap values from /var/run/secrets/kubernetes.io/serviceaccount