I am creating a config map as below
kubectl create configmap testconfigmap --from-file=testkey=testfile.txt
As I am using helm charts, I would like to create the config map using YAML file instead of running kubectl, so something like:
apiVersion: v1
kind: ConfigMap
metadata:
name: testconfigmap
data:
fromfile: testkey=testfile.txt
The --from-file
allows me to pass the key and the value I read from the testfile.txt. But the fromfile
doesn't work if I create configMap as YAML file.
The following command will generate the Yaml file you need to apply
kubectl create configmap testconfigmap —from-file=testkey=test file.txt —dry-run=client -o yaml > myconfigmap.yaml
Then you can just do
kubectl apply -f myconfigmap.yaml