Hossam Hassan:
Hello Guys,
I have created a config map my-config from a file configmapDataSource
hoss@localhost ~]$ cat configmapDataSource
key1=value1
key2=value2
key3=value3
key4=value4
key5=value5
key6=value6
using the below command
kubectl create configmap my-config --from-file=/home/hoss/configmapDataSource
config map my config
hoss@localhost ~]$ kubectl describe configmaps my-config
Name: my-config
Namespace: default
Labels: <none>
Annotations: <none>
Data
====
configmapDataSource:
----
key1=value1
key2=value2
key3=value3
key4=value4
key5=value5
key6=value6
BinaryData
====
Events: <none>
Then i have created a pod mypod which reference my-config key2
Mypod yaml
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: "2023-02-20T00:42:21Z"
labels:
run: mypod
name: mypod
namespace: default
resourceVersion: "209591"
uid: cb9161da-887e-439d-9509-fb88c23178b5
spec:
containers:
- env:
- name: test
valueFrom:
configMapKeyRef:
key: key2
name: my-config
Now the pod is giving a config error that it cant find key2 in my config
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Pulling 2s kubelet Pulling image “redis”
Normal Pulled 0s kubelet Successfully pulled image “redis” in 1.691770932s (1.691794944s including waiting)
Warning Failed 0s kubelet Error: couldn’t find key key2 in ConfigMap default/my-config
The question here why the pod can’t find the key while it shows in the configmap ?
Another question when i add new value in configmapDataSource its not added to the config map ?