<p>I am trying to define the namespace name when executing the <code>kubectl create deployment</code> command?</p>

<p>This is what I tried:</p>

<p><code>kubectl create deployment test --image=banu/image1 namespace=test</code></p>

<p>and this doesn't work.</p>

<p>And I want to expose this deployment using a <code>ClusterIP</code> service within the cluster itself <code>for that given namespace</code> How can I do that using <code>kubectl</code> command line?</p>

<p>You can specify either <code>-n</code> or <code>--namespace</code> options.</p>

<p><code>kubectl create deployment test --image=nginx --namespace default --dry-run -o yaml</code> and see result deployment yaml.</p>

<p>Using <code>kubectl run</code></p>

<pre class="lang-sh prettyprint-override"><code>kubectl run test --namespace test --image nginx  --port 9090 --dry-run -o yaml
</code></pre>
