<p>I was wondering if there is an easier way to create daemonsets in k8s other than yaml files.
For eg, for pods we have <code>kubectl run --generator=run-pod/v1</code> command. I was wondering if there is something similar for DS.</p>

<p>Thanks in advance.</p>

Naxi
<p>There is no such quick <code>kubectl create</code> type command for creating <code>daemonsets</code>. But you can do it in some other way.</p>
<ul>
<li>One way to do this is:
<pre class="lang-bash prettyprint-override"><code>$ kubectl create deploy nginx --image=nginx --dry-run=client -o yaml | \
    sed '/null\|{}\|replicas/d;/status/,$d;s/Deployment/DaemonSet/g' &gt; nginx-ds.yaml
$ kubectl apply -f nginx-ds.yaml
</code></pre>
</li>
<li>If you don't want to save the <code>yaml</code> data to any file, here's how you can do this:
<pre class="lang-bash prettyprint-override"><code>$ kubectl create deploy nginx --image=nginx --dry-run=client -o yaml | \
    sed '/null\|{}\|replicas/d;/status/,$d;s/Deployment/DaemonSet/g' | \
    kubectl apply -f -
</code></pre>
</li>
</ul>
<p>You have your daemonset now.</p>
<p>What we are doing here is: at first we're creating a deployment <code>yaml</code> and then replacing <code>kind: Deployment</code> with <code>kind: DaemonSet</code> and remove <code>replicas: 1</code> from the deployment <code>yaml</code>.</p>
<p>Thats's how we get <code>yaml</code> for <code>daemonset</code>.</p>
