lets take this example of a config map
apiVersion: v1
kind: ConfigMap
data:
abc.yml: |-
<yml here>
Getting an error like failed to parse yaml to Json.
lets take this example of a config map
apiVersion: v1
kind: ConfigMap
data:
abc.yml: |-
<yml here>
Getting an error like failed to parse yaml to Json.
Create
ConfigMap
from file.kubectl create configmap myconfig --from-file=youfile.yml
.You can check more examples on kubernetes docs
Yes you can do that, but you should care about the syntax. You can also follow techniques for yaml from here.
If you use
kubectl create configmap myconfig --from-file=abc.yml
, then it is ok.But if you write the whole yaml file for your configmap in myconfig.yaml and then run
kubectl create -f myconfig.yaml
, then you should care about syntax.Say your
abc.yml
file is as followings:Then write your
myconfig.yaml
file:Now just run
kubectl create -f myconfig.yaml
. That's it.Happy Kubernetes!!!.
These could be the problems 1. most likely the issue could with the indentation. 2. remove '-' from abc.yml: |- and check
I followed the below steps and was able to load yaml file into configmap. it worked fine.