Which command applies a ConfigMap as environment variables to a DeploymentConfig?

Prepare for the Red Hat OpenShift Developer II DO288 Exam with our quizzes. Study with flashcards and multiple choice questions, each with hints and explanations. Get ready for your certification!

Multiple Choice

Which command applies a ConfigMap as environment variables to a DeploymentConfig?

Explanation:
Injecting environment variables from a ConfigMap into a DeploymentConfig is done by updating the DeploymentConfig’s environment with the set env command and using the ConfigMap as the source. The correct approach is to run a command that targets the DeploymentConfig and references the ConfigMap with --from. For example, oc set env dc/<name> --from cm/<name>. This tells OpenShift to take every key/value pair in the ConfigMap and expose them as environment variables in the DeploymentConfig’s pods. This works because the set env operation is designed to modify a resource’s environment, and --from cm/<name> is the standard way to pull a ConfigMap’s data into the environment of the target resource. The other forms don’t fit: the syntax with oc env set is not the correct command structure, oc set-env is not the proper command, and pointing from a DeploymentConfig to a ConfigMap or referencing resources in the opposite direction would apply the data to the wrong resource (or not at all). After applying the change, a rollout will recreate pods so the new environment variables are picked up by the containers.

Injecting environment variables from a ConfigMap into a DeploymentConfig is done by updating the DeploymentConfig’s environment with the set env command and using the ConfigMap as the source. The correct approach is to run a command that targets the DeploymentConfig and references the ConfigMap with --from. For example, oc set env dc/ --from cm/. This tells OpenShift to take every key/value pair in the ConfigMap and expose them as environment variables in the DeploymentConfig’s pods.

This works because the set env operation is designed to modify a resource’s environment, and --from cm/ is the standard way to pull a ConfigMap’s data into the environment of the target resource. The other forms don’t fit: the syntax with oc env set is not the correct command structure, oc set-env is not the proper command, and pointing from a DeploymentConfig to a ConfigMap or referencing resources in the opposite direction would apply the data to the wrong resource (or not at all). After applying the change, a rollout will recreate pods so the new environment variables are picked up by the containers.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy