<p>I have about 10 ConfigMap and few secrets which stores my configuration in key and value. I am looking for any kubectl command which i can use to find my key in any available configMap or secrets ?
I know I can open each file and find my key but is there any <code>kubectl</code> command which lookup all configMap or Serects to find my key?</p>

<p>Create the following kubectl plugin</p>
<pre><code>#!/bin/bash

kubectl get secrets -o go-template='{{range $s:=.items}}{{range $k,$v:=$s.data}}{{printf &quot;Secret %s: %s\n&quot; $s.metadata.name $k}}{{end}}{{end}}' | grep -i $1
kubectl get configmap -o go-template='{{range $s:=.items}}{{range $k,$v:=$s.data}}{{printf &quot;CM %s: %s\n&quot; $s.metadata.name $k}}{{end}}{{end}}' | grep -i $1
</code></pre>
<p>It will have to be located somewhere on your execution path and be executable</p>
<pre><code># Make script executable
chmod +x /home/mark/bin/kubectl-find-key

# Check it can be found
kubectl plugin list
</code></pre>
<p>Lastly it can be used as follows</p>
<pre><code>$ kubectl find key database
CM myapp-details: DATABASE_HOSTNAME
</code></pre>
