I have created a configMap from a file using "kustomize", then i am passing the key/value pairs from the configMap to the container as environment variables, when i EXEC into the container and write "env" the pairs seem to show up, but when i try to access one of them like "echo $VARNEM", nothing shows up.
first i wrote this test 'config1.properties' file
JIN=bombay
RUM=bacardi
WHISKY=jhonny walker
then i converted it to a configMap using kustomize
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- k8s.yaml
configMapGenerator:
- name: map1
files:
- config1.properties
then i converted the map to environment variables in the deployment file (this is under the 'container' section)
env:
- name: map-envs
valueFrom:
configMapKeyRef:
name: map1-kt62t9247m
key: config1.properties
finally when i EXEC into the container, it does show up, additionally this is how it shows on the cluster tree
but when i try to access the var, it shows as null, so as for my node.js app when i try to reach it from there.
I think it's something about the whole config file being treated as a key of the 'map1-kt62t9247m' but i haven't managed to fixed it by myself.