Is there a particular scenario in which we use `from-file` vs `from-env-file` wh . . .

Dhawan Shringi:
Is there a particular scenario in which we use from-file vs from-env-file while creating the configmap?

Also when I create a configmap using --from-file with content let’s say a=b the configmap looks like below:

Name:         temp-cm
Namespace:    default
Labels:       <none>
Annotations:  <none>

Data
====
data-file:
----
a=b

The problem with the above is I can’t reference a as key in a configMapKeyRef , am I missing something here?

Dhawan Shringi:
From what I understand after some reading, from-file refers to the whole file content as a value with file name being the key however in case of from-env-file every key value pair of file becomes a key value pair in the configmap.

Dhawan Shringi:
Which explains why --from-file parameter allows the file name to be overridden in the command and the --from-env-file doesn’t.

Edith Puclla:
@Dhawan Shringi according your first question, this is one where you should use from-file:
110. Create a configmap named keyvalcfgmap and read data from the file config.txt and verify that configmap is created correctly

Mohamed Ayman:
Check this

https://alibaba-cloud.medium.com/how-to-create-and-use-configmaps-in-kubernetes-e6d1e0b150b4|https://alibaba-cloud.medium.com/how-to-create-and-use-configmaps-in-kubernetes-e6d1e0b150b4

Dhawan Shringi:
Thanks @Mohamed Ayman, that’s as elaborate as it could get and certainly helped affirm my understanding! :thumbsup: