

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 4
click for more info
No active XP Potion
Accept a Quest
Login to submit answers
There are several ways to manage environment variables in Kubernetes. One of the most common ways is to use ConfigMaps. ConfigMaps allow us to decouple our configurations from our container images, which is important because we don't want to have to rebuild our images every time we want to change a configuration value.
In a Dockerfile we can set environment variables like this:
ENV PORT=3000
The trouble is, that means that everyone using that image will have to use port 3000. It also means that if we want to change the port, we have to rebuild the image.
First, let's take a closer look at our crashing pod and try to figure out why it's crashing.
kubectl get pods
Copy the pod name and then get the logs:
kubectl logs <pod-name>
You should see that a specific environment variable is missing! Let's fix that.
Create a new file. Let's call it api-configmap.yaml. Add the following YAML to it:
apiVersion: v1kind: ConfigMapmetadata/name: synergychat-api-configmapdata/API_PORT: "8080"Next, apply the config map:
kubectl apply -f api-configmap.yaml
Now, we haven't yet connected the config map to our pod, so it should still be crashing. However, for now, let's just validate that the config map was created successfully:
kubectl get configmaps
Run:
kubectl proxy
Run and submit the CLI tests.
The Boot.dev CLI requires you to be signed in to submit your solution!
Copy/paste one of the following commands into your terminal:
Run
bootdev run 9eb61c75-e1c4-4e1c-9d57-984575974e0d
Submit
bootdev run 9eb61c75-e1c4-4e1c-9d57-984575974e0d -s
To run and submit the tests for this lesson, you must have an active Boot.dev membership
Become a member to view solution
Using the Bootdev CLI
The Bootdev CLI is the only way to submit your solution for this type of lesson. We need to be able to run commands in your environment to verify your solution.
You can install it here. It's a Go program hosted on GitHub, so you'll need Go installed as well. Instructions are on the GitHub page.