<p>I'm trying to save the contents of a configmap to a file on my local hard drive. Kubectl supports selecting with JSONPath but I can't find the expression I need to select just the file contents.</p>

<p>The configmap was created using the command</p>

<pre><code>kubectl create configmap my-configmap --from-file=my.configmap.json=my.file.json
</code></pre>

<p>When I run </p>

<pre><code>kubectl describe configmap my-configmap
</code></pre>

<p>I see the following output:</p>

<pre><code>Name:         my-configmap 
Namespace:    default 
Labels:       &lt;none&gt; 
Annotations:  &lt;none&gt;

Data
==== 
my.file.json:
---- 
{
    "key": "value" 
} 
Events:  &lt;none&gt;
</code></pre>

<p>The furthest I've gotten so selecting only the file contents is this:</p>

<pre><code> kubectl get configmap my-configmap -o jsonpath="{.data}"
</code></pre>

<p>Which outputs</p>

<pre><code>map[my.file.json:{
    "key": "value"
}]
</code></pre>

<p>The output that I want is </p>

<pre><code>{
  "key": "value"
}
</code></pre>

<p>What is the last piece of the JSONPath puzzle?</p>

PeterH
<p>There’s an open <a href="https://github.com/kubernetes/kubernetes/issues/63503" rel="noreferrer">issue</a> at the Kubernetes GitHub repo with a list of things that needs to be fixed in regards to kubectl (and JSONpath), one of them are issue <a href="https://github.com/kubernetes/kubernetes/issues/16707" rel="noreferrer">16707</a> <em>jsonpath template output should be json</em>. </p>

<p><strong>Edit:</strong></p>

<p>How about this:</p>

<pre><code>kubectl get cm my-configmap -o jsonpath='{.data.my\.file\.json}'
</code></pre>

<p>I just realized i had <a href="https://stackoverflow.com/a/51052288/1547081">answered</a> another question related (kind of) to this one. The above command should output what you had in mind!</p>
