<p>I can create a secret using a single line command like so:</p>
<pre><code>kubectl -n myns create secret generic my-secret --from-literal=type=super --from-literal=url=example.com --from-file=samples=sample.txt
</code></pre>
<p>But it's missing a label when this is created. I want to keep it as a single line command.</p>
<p>Can I pass in a label parameter or do i need to do a second call to modify the created secret?</p>

<p>There isn't an option in the <code>kubectl create secret</code> command to add a label.</p>
<p>You will need to run a second command to add the label:</p>
<pre class="lang-bash prettyprint-override"><code>kubectl label secret my-secret -n myns &quot;foo=bar&quot;
</code></pre>
<p>But you could technically do it on one line like:</p>
<pre class="lang-bash prettyprint-override"><code>kubectl create secret generic my-secret ... &amp;&amp; kubectl label secret my-secret &quot;foo=bar&quot;
</code></pre>
<p>Or do as <a href="https://stackoverflow.com/a/72467037/2446208">@larsks suggests</a> which is much better for job security.</p>
