<p>I would like to use <code>kubectl</code> to print out all key-value pairs in my Secrets. I cannot figure out how to do this in one line with the <code>-o --jsonpath</code> flag or by piping into <code>jq</code>. I could certainly make a script to do this but I feel there must be a better way, given that the kubernetes GUI is pretty straightforward and liberal when it comes to letting you view Secrets.</p>

<p>Say I create secret like so:</p>

<p><code>kubectl create secret generic testsecret --from-literal=key1=val1 --from-literal=key2=val2</code></p>

<p>Now I can run <code>kubectl get secret testsecret -o json</code> to get something like:</p>

<pre><code>{
    "apiVersion": "v1",
    "data": {
        "key1": "dmFsMQ==",
        "key2": "dmFsMg=="
    },
    ...
}
</code></pre>

<p>I can do something like</p>

<p><code>kubectl get secret testsecret -o jsonpath='{.data}'</code> </p>

<p>or </p>

<p><code>kubectl get secret testsecret -o json | jq '.data'</code></p>

<p>to get my key-value pairs in <em>non-list</em> format then I'd have to <code>base64 --decode</code> the values.</p>

<p>What is the easiest way to get a clean list of all my key-value pairs? Bonus points for doing this across all Secrets (as opposed to just one specific one, as I did here).</p>

<p>I read this question as asking for how to decode <em>all secrets</em> in one go.  I built on the accepted answer to produce a one-liner to do this:</p>
<pre><code>kubectl get secrets -o json | jq '.items[] | {name: .metadata.name,data: .data|map_values(@base64d)}'
</code></pre>
<p>This has the added benefit of listing the name of the secret along with the decoded values for readability.</p>
