<p>How can I retrieve a configmap value using jsonpath?</p>
<p>I'm trying to retrieve the value of haproxy.cfg from my configmap, but I can't get it just right:</p>
<pre><code>kubectl get cm -l app=haproxy -o jsonpath=&quot;{['items'][0]['data']['haproxy.cfg']}&quot;
</code></pre>
<p>The above returns no results.  But I can definitely get the configmap if I leave off the haproxy.cfg:</p>
<pre><code>kubectl get cm -l app=haproxy -o jsonpath=&quot;{['items'][0]['data']}&quot;
</code></pre>
<p>Yields:</p>
<pre><code>map[haproxy.cfg:
global
  user root
  group root
  maxconn 256
...
]
</code></pre>
<p>I can use jq:</p>
<pre><code>kubectl get cm -l app=haproxy -o json | jq -r '.items[0].data[&quot;haproxy.cfg&quot;]'
</code></pre>
<p>which yields exactly what I want:</p>
<pre><code>
global
  user root
  group root
  maxconn 256

</code></pre>
<p>If you need help creating your ConfigMap, here's the manifest for the one I am using:</p>
<pre><code>apiVersion: v1
data:
    haproxy.cfg: &quot;\nglobal\n  user root\n  group root\n  maxconn 256\n\n&quot;
kind: ConfigMap
metadata:
    annotations:
      meta.helm.sh/release-name: haproxy
      meta.helm.sh/release-namespace: haproxy
    labels:
      app: haproxy
      app-version: 2.4.0
      app.kubernetes.io/managed-by: Helm
      heritage: Helm
      release: haproxy
      version: 0.0.3
    name: haproxy
</code></pre>

<p>Escape the <code>.</code> inside single quotes</p>
<pre><code>kubectl get cm -l app=haproxy -o jsonpath=&quot;{.items[0].data['haproxy\.cfg']}&quot;
</code></pre>
<p>* This didn't work a long time ago, pre 1.5. Then you needed to use <code>go-template</code> formatting.</p>
