I don't know what i did wrong on Mock 5 test of Ultimate Certified Kubernetes Administrator (CKA) Mock Exam Series

Task
SECTION: SCHEDULING

For this question, please set the context to cluster3 by running:

kubectl config use-context cluster3

On cluster3, there is a web application pod running inside the default namespace. This pod which is part of a deployment called webapp-color-wl10 and makes use of an environment variable that can change constantly. Add this environment variable to a configmap and configure the pod in the deployment to make use of this config map.

Use the following specs-

  1. Create a new configMap called webapp-wl10-config-map with the key and value as - APP_COLOR=red.

  2. Update the deployment to make use of the newly created configMap name.

  3. Delete and recreate the deployment if necessary.

My solution was:

kubectl config use-context cluster3
kubectl create configmap webapp-wl10-config-map --from-literal=APP_COLOR=red

kubectl edit deployment webapp-color-wl10

apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: webapp-color-wl10
name: webapp-color-wl10
namespace: default
resourceVersion: “1846”
spec:
replicas: 2
selector:
matchLabels:
app: webapp-color-wl10
template:
metadata:
creationTimestamp: null
labels:
app: webapp-color-wl10
spec:
containers:
- env:
- name: APP_COLOR
valueFrom:
configMapKeyRef:
key: APP_COLOR
name: webapp-wl10-config-map
image: kodekloud/webapp-color
name: webapp-color-wl10

k exec webapp-color-wl10-7649cdd948-px9xz – env
PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=webapp-color-wl10-7649cdd948-px9xz
LANG=C.UTF-8
GPG_KEY=0D96DF4D4110E5C43FBFB17F2D347EA6AA65421D
PYTHON_VERSION=3.6.6
PYTHON_PIP_VERSION=18.1
APP_COLOR=red
WEBAPP_COLOR_WL10_SERVICE_PORT_8080_TCP=tcp://10.43.81.189:8080
KUBERNETES_SERVICE_PORT_HTTPS=443
KUBERNETES_PORT_443_TCP_PORT=443
WEBAPP_COLOR_WL10_SERVICE_SERVICE_PORT=8080
WEBAPP_COLOR_WL10_SERVICE_PORT_8080_TCP_PORT=8080
KUBERNETES_SERVICE_PORT=443
KUBERNETES_PORT=tcp://10.43.0.1:443
KUBERNETES_PORT_443_TCP_ADDR=10.43.0.1
WEBAPP_COLOR_WL10_SERVICE_SERVICE_HOST=10.43.81.189
KUBERNETES_SERVICE_HOST=10.43.0.1
KUBERNETES_PORT_443_TCP=tcp://10.43.0.1:443
KUBERNETES_PORT_443_TCP_PROTO=tcp
WEBAPP_COLOR_WL10_SERVICE_PORT=tcp://10.43.81.189:8080
WEBAPP_COLOR_WL10_SERVICE_PORT_8080_TCP_PROTO=tcp
WEBAPP_COLOR_WL10_SERVICE_PORT_8080_TCP_ADDR=10.43.81.189
HOME=/root

as you can see APP_COLOR is been set by the configmap as required by the task

The labs checker said my solution was wrong and i don’t understand why.
The oficial solucion is

Solution
Set the correct context: -

kubectl config use-context cluster3

Inspect the given pod in the default namespace: -

kubectl get pods -n default

Let’s create a new configMap in the default namespace as follows:-

kubectl create configmap webapp-wl10-config-map --from-literal=APP_COLOR=red

And now configure the newly created configmap to the web application pod’s template: -


apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: webapp-color-wl10
name: webapp-color-wl10
namespace: default
spec:
replicas: 2
selector:
matchLabels:
app: webapp-color-wl10
template:
metadata:
labels:
app: webapp-color-wl10
spec:
containers:
- image: kodekloud/webapp-color
name: webapp-color-wl10
envFrom:
- configMapRef:
name: webapp-wl10-config-map

The only diference i could see was the method on defining the variable that was diferent

I’m not sure which Mock Exam you’re doing here – I believe there are six of them – or which question number; if you want me to check the problem, I’ll need to know that. But just on the basis of what I do know, it appears that that the grader wants you to use envFrom rather than valueFrom to interact with the configMap. That would be my guess, at any rate.

but where in the text does he ask for this?

i wrote the whole assignment

The lab might not say this explicitly. Sometimes this is simply an implementation choice.