<p>I have a statefulset which has a nodeSelector:</p>
<pre><code>  nodeSelector:
    app: licensed
</code></pre>
<p>When I assign the node with <code>app: licensed</code>, I can see the pod is schedule on a specific node.</p>
<p>But when I remove the label from the node, I don't see k8s remove the pod from that node. I have to explicitly delete the pod.</p>
<p>Is it a kubernetes feature? Or did I use the nodeSelector correctly?</p>

Kintarō
<p>The thing you're looking for is likely <a href="https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/#taint-based-evictions" rel="nofollow noreferrer">taints and tolerations</a> if you want only designated things to run on designated Nodes. The <code>nodeSelector:</code> you used is used in the scheduling decision, but is not used in the reconciliation loop <em>(as you experienced)</em></p>
<p>There is more fine grained control via the <code>effect: NoSchedule</code>, which as it implies will keep a Pod merely from being scheduled if it doesn't tolerate the taint, and <code>effect: NoExecute</code> which is closer to what you're asking for where if a taint <em>appears</em> on a Node, and the Pod doesn't tolerate it, the Pod will be evicted and not rescheduled upon any such tainted Node. Modern versions of kubernetes allow even finer grained control via the <code>PreferNoSchedule</code> and the opposite end of that with <code>tolerationSeconds</code> to give some padding around how soon any such eviction may happen</p>
