Chhandak Dey:
Hi All,
I have a doubt of using config map created from a file in the pod as environment variables. Below are the steps what I have done,
Step 1=> I have created a text file config.txt
-> echo $‘key1=value1\nkey2=value2’
Step 2 => Created config map
-> k create cm keyvalcfgmap --from-file=config.txt
=> yaml view of the cm keyvalcfgmap
apiVersion: v1
data:
config.txt: |
key1=value1
key2=value2
kind: ConfigMap
metadata:
creationTimestamp: “2022-01-17T13:21:57Z”
name: keyvalcfgmap
namespace: default
resourceVersion: “127717”
uid: 6ca5e263-b9d4-405d-a40c-e0780de2bace
Step 3 => Create a pod
1 apiVersion: v1
2 kind: Pod
3 metadata:
4 creationTimestamp: null
5 labels:
6 run: nginx
7 name: nginx
8 namespace: default
9 spec:
10 containers:
11 - image: nginx
12 name: nginx
13 resources: {}
14 envFrom:
15 - configMapRef:
16 name: keyvalcfgmap
17 dnsPolicy: ClusterFirst
18 restartPolicy: Never
19 status: {}
However when I check the environment variables inside the container, it is coming like -
PKG_RELEASE=1~bullseye
config.txt=key1=value1
key2=value2
KUBERNETES_PORT=tcp://10.8.0.1:443
Can anyone please check and tell me what I am missing?