<p>is there any way to avoid execution of an application deployed as DaemonSet on master?<br>
I have seen that this is the expected behavior, but I would like to avoid execution in some way.   </p>

<p>Regular pods will not schedule on master but DaemonSet pods do.   </p>

<p>If yes, is it possible to set this information in the yml file (parameter..etc??)?</p>

<pre><code> kubectl create -f mydaemon.yml

logspri-4zwl4              1/1       Running           0          &lt;invalid&gt;   X.X.X.X   k8s-master-e7c355e2-0
logspri-kld2w              1/1       Running           0          &lt;invalid&gt;   X.X.X.X     k8s-agent-e7c355e2-0
logspri-lksrh              1/1       Running           0          &lt;invalid&gt;   X.X.X.X     k8s-agent-e7c355e2-1
</code></pre>

<p>I would like to avoid my pod is running on <code>k8s-master-e7c355e2-0</code></p>

<p>I have tried :   </p>

<pre><code>annotations:
          scheduler.alpha.kubernetes.io/affinity: &gt;
            {
              "nodeAffinity": {
                "requiredDuringSchedulingRequiredDuringExecution": {
                  "nodeSelectorTerms": [
                    {
                      "matchExpressions": [
                        {
                          "key": "kubernetes.io/role",
                          "operator": "NotIn",
                          "values": ["master"]
                        }
                      ]
                    }
                  ]
                }
              }
            }
</code></pre>

<p>Trying also to apply the following role  (as suggested) but it doesn't work :   </p>

<pre><code>kubectl get nodes
NAME                    STATUS                     AGE       VERSION
k8s-agent-e7c355e2-0    Ready                      49d       v1.5.3
k8s-agent-e7c355e2-1    Ready                      49d       v1.5.3
k8s-master-e7c355e2-0   Ready,SchedulingDisabled   49d       v1.5.3
</code></pre>

<p>Shall I perform:      </p>

<pre><code>VirtualBox:~/elk/logspout$ kubectl taint node k8s-master-e7c355e2-0 k8s-master-e7c355e2-0/ismaster=:NoSchedule
node "k8s-master-e7c355e2-0" tainted
</code></pre>

<p>Even if it seems that the master is tainted I see that the application is always on master.   </p>

<pre><code>Role:           
Labels:         beta.kubernetes.io/arch=amd64
            beta.kubernetes.io/instance-type=Standard_D2
            beta.kubernetes.io/os=linux
            failure-domain.beta.kubernetes.io/region=northeurope
            failure-domain.beta.kubernetes.io/zone=0
            kubernetes.io/hostname=k8s-master-e7c355e2-0
Annotations:        volumes.kubernetes.io/controller-managed-attach-detach=true
Taints:         &lt;none&gt;
CreationTimestamp:  Wed, 17 May 2017 14:38:06 +0200
Phase:          
Conditions:
</code></pre>

<p>What is wrong?
Could you give me the right command to perform?</p>

<p>same problem reported <a href="https://stackoverflow.com/questions/42134518/cluster-created-with-kops-deploying-one-pod-by-node-with-daemonset-avoiding-ma">here</a> without an apparent solution by :   </p>

<pre><code>kubectl taint nodes nameofmaster dedicated=master:NoSchedule
</code></pre>

<p>Thanks
Prisco</p>

<p>By <code>Even if it seems that the master is tainted I see that the application is always on master.</code>, I'm not certain if the DaemonSet was created before or after the taint.</p>

<p>If you tainted first and then created the DaemonSet, the pod should be repelled by the tainted node without further config. Otherwise, the pod from the DaemonSet will not automatically terminate. To evict existing pods immediately, the <code>NoExecute</code> taint is needed.</p>

<p>From <a href="https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#taints-and-tolerations-beta-feature" rel="nofollow noreferrer">here</a>:</p>

<blockquote>
  <p>Normally, if a taint with effect NoExecute is added to a node, then
  any pods that do not tolerate the taint will be evicted immediately,
  and any pods that do tolerate the taint will never be evicted.
  However, a toleration with NoExecute effect can specify an optional
  tolerationSeconds field that dictates how long the pod will stay bound
  to the node after the taint is added.</p>
</blockquote>
