<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>Alwyn&#x27;s Blog - certificates</title>
    <subtitle>Sometimes hyper-specific technical musings</subtitle>
    <link rel="self" type="application/atom+xml" href="https://blog.alwyn.io/tags/certificates/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://blog.alwyn.io"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2026-07-16T00:00:00+00:00</updated>
    <id>https://blog.alwyn.io/tags/certificates/atom.xml</id>
    <entry xml:lang="en">
        <title>Protip: find deployments mounting Kubernetes secret</title>
        <published>2026-07-16T00:00:00+00:00</published>
        <updated>2026-07-16T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              alveel
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://blog.alwyn.io/blog/kubernetes-secret-mounts/"/>
        <id>https://blog.alwyn.io/blog/kubernetes-secret-mounts/</id>
        
        <content type="html" xml:base="https://blog.alwyn.io/blog/kubernetes-secret-mounts/">&lt;p&gt;Useful one-liner to find all workloads that mount a specific secret:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;export secret_name=foo kubectl get deploy,statefulset,daemonset,job,cronjob -A -o json | jq -r --arg s $secret_name &amp;#39;.items[] | select([.. | objects | .secretName?, .secretKeyRef?.name, .secretRef?.name, .secret?.name] | any(. == $s)) | &amp;quot;\(.metadata.namespace) \(.kind)&#x2F;\(.metadata.name)&amp;quot;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This recursively searches for all &lt;code&gt;secretName&lt;&#x2F;code&gt;, &lt;code&gt;secretKeyRef&lt;&#x2F;code&gt;, &lt;code&gt;secretRef&lt;&#x2F;code&gt; and &lt;code&gt;secret&lt;&#x2F;code&gt; keys, taking into account all forms of referencing a secret (&lt;code&gt;(deploy|sts|ds,job).spec.(job)template&lt;&#x2F;code&gt; assumed):&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;.spec.volumes.secret.secretName&lt;&#x2F;code&gt; - &quot;classic&quot; secret volume&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;.spec.volumes.projected.sources.secret.name&lt;&#x2F;code&gt; - projected source&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;.spec.containers.env.valueFrom.secretKeyRef.name&lt;&#x2F;code&gt; - for a specific environment variable&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;.spec.containers.envFrom.secretRef.name&lt;&#x2F;code&gt; - for populating environment variables from a secret&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
</feed>
