This article provides a step-by-step solution for managing ConfigMaps and environment variables in Kubernetes pods.
Hi, I’m Sanjeev, one of the co-instructors for this course. In this lesson, we will walk through the solution for the ConfigMap section of the assignment in a step-by-step manner.─────────────────────────────
From the Environment section, note that the variable APP_COLOR is set (ensure you select the correct one if multiple similar names are present).─────────────────────────────
Click on the web app color tab to open the application in your browser. When the page loads, you should see the application displaying the color corresponding to the APP_COLOR value (in this case, pink). Once confirmed, click OK to proceed.
5. Updating the Environment Variable for a Green Background
The next task is to update the pod configuration so that the background changes to green. This involves deleting and recreating the pod with the necessary modification while keeping the pod name unchanged.
Open the exported pod.yaml file in your favorite text editor, such as using vi:
Copy
Ask AI
vi pod.yaml
Locate the env section under the container definition and change the value of APP_COLOR from pink to green. Save your modifications.Apply the updated configuration:
Copy
Ask AI
kubectl apply -f pod.yaml
Finally, verify that the pod is running and that the background has changed to green.
Update the pod.yaml file to reference the ConfigMap rather than using a hard-coded environment variable value. Modify the container specification under the env section as follows:
Finally, open the web app color interface once more and refresh the page. Confirm that the background has successfully changed to darkblue. When this change is verified, click OK to complete the exercise.─────────────────────────────
This concludes the assignment for the ConfigMap lab session.
Ensure that you carefully check the environment variable sections in both the pod description and the YAML file when making updates to avoid configuration errors.