<p>lets take this example of a config map</p>

<pre><code>apiVersion: v1
kind: ConfigMap
data:
  abc.yml: |-
&lt;yml here&gt;
</code></pre>

<p>Getting an error like failed to parse yaml to Json.</p>

<p>Yes you can do that, but you should care about the syntax. You can also follow techniques for yaml from <a href="https://github.com/helm/helm/blob/master/docs/chart_template_guide/yaml_techniques.md#strings-in-yaml" rel="nofollow noreferrer">here</a>.</p>

<p>If you use <code>kubectl create configmap myconfig --from-file=abc.yml</code>, then it is ok.</p>

<p>But if you write the whole yaml file for your configmap in myconfig.yaml and then run <code>kubectl create -f myconfig.yaml</code>, then you should care about syntax.</p>

<p>Say your <code>abc.yml</code> file is as followings:</p>

<pre><code>a:
  b: b1
  c: c1
d: d1
</code></pre>

<p>Then write your <code>myconfig.yaml</code> file:</p>

<pre><code>apiVersion: v1
kind: ConfigMap
data:
  abc.yml: |
    a:
      b: b1
      c: c1
    d: d1
</code></pre>

<p>Now just run <code>kubectl create -f myconfig.yaml</code>.
That's it.</p>

<p>Happy Kubernetes!!!.</p>
