Add an environment variable to a deployment myapp from a config map cm1?

Prepare for the Red Hat Openshift Developer EX288 Exam. Study with comprehensive quizzes and flashcards. Each question includes hints and explanations to enhance your understanding. Ace your exam with confidence!

Multiple Choice

Add an environment variable to a deployment myapp from a config map cm1?

Explanation:
The operation uses an environment variable injection from a ConfigMap by telling the deployment to pull all keys from that ConfigMap and expose them as environment variables in the pod’s containers. Using the command with --from configmap/cm1 specifies the source type (ConfigMap) and the ConfigMap name (cm1), so each key in cm1 becomes an environment variable in the deployment’s pods. This is the correct approach because it directly maps the ConfigMap’s data into the container environment. Why the other forms don’t fit: omitting the type (just --from cm1) isn’t valid syntax because the source must be prefixed with configmap/ to indicate the ConfigMap source. Using --from-file would bring in values from a file, not from a ConfigMap, so it wouldn’t populate env vars from cm1. After applying, remember that existing pods won’t automatically pick up new values—you’d need a rollout restart to apply changes to running pods.

The operation uses an environment variable injection from a ConfigMap by telling the deployment to pull all keys from that ConfigMap and expose them as environment variables in the pod’s containers. Using the command with --from configmap/cm1 specifies the source type (ConfigMap) and the ConfigMap name (cm1), so each key in cm1 becomes an environment variable in the deployment’s pods. This is the correct approach because it directly maps the ConfigMap’s data into the container environment.

Why the other forms don’t fit: omitting the type (just --from cm1) isn’t valid syntax because the source must be prefixed with configmap/ to indicate the ConfigMap source. Using --from-file would bring in values from a file, not from a ConfigMap, so it wouldn’t populate env vars from cm1. After applying, remember that existing pods won’t automatically pick up new values—you’d need a rollout restart to apply changes to running pods.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy