<p>As I know the way to create a configMap in Kubernetes from a file is to use:<br />
<code>--from-file</code> option for <code>kubectl</code></p>
<p>What I am looking for is a way to only load part of the yaml file into the configMap.<br />
Example:
Let's say I have this yml file:</p>
<pre><code>family:
  Boys:
    - name: Joe
    - name: Bob
    - name: dan
  Girls:
    - name: Alice
    - name: Jane  
</code></pre>
<p>Now I want to create a configMap called 'boys' which will include only the 'Boys' section.<br />
Possible?</p>
<p>Another thing that could help if the above is not possible is when I am exporting the configMap as environment variables to a pod (using <code>envFrom</code>) to be able to only export part of the configMap.<br />
Both options will work for me.</p>
<p>Any idea?</p>

nsteiner
<p>The ConfigMap uses a key and value for its configuration. Based on your example, you get multiple arrays of data where there are multiple values with their own keys. But you can create multiple ConfigMap from different file for these issues.</p>
<ol>
<li>First you need to create .yaml files  to create a ConfigMap guided by the <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#create-configmaps-from-files" rel="nofollow noreferrer">documentation</a>.
First file call <code>Boys.yaml</code></li>
</ol>
<pre><code># Env-files contain a list of environment variables.
# These syntax rules apply:
# Each line in an env file has to be in VAR=VAL format.
# Lines beginning with # (i.e. comments) are ignored.
# Blank lines are ignored.
# There is no special handling of quotation marks (i.e. they will be part of the ConfigMap value)).

name=Joe
name=Bob
name=Dan
</code></pre>
<p>Second file call <code>Girls.yaml</code></p>
<pre><code>name=Alice
name=Jane
</code></pre>
<ol start="2">
<li>Create your ConfigMap</li>
</ol>
<pre><code>kubectl create configmap NmaeOfYourConfigmap --from-env-file=PathToYourFile/Boys.yaml
</code></pre>
<ol start="3">
<li>where the output is similar to this:</li>
</ol>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  creationTimestamp: 
  name: NmaeOfYourConfigmap
  namespace: default
  resourceVersion: 
  uid:
data:
  name: Joe
  name: Bob
  name: Dan
</code></pre>
<ol start="4">
<li>Finally, you can pass these ConfigMap to pod or deployment using <code>configMapRef</code> entries:</li>
</ol>
<pre><code>        envFrom:
          - configMapRef:
              name: NmaeOfYourConfigmap-Boys
          - configMapRef:
              name: NmaeOfYourConfigmap-Girls
</code></pre>
