<p>I  need to provide a list of hostnames under <code>kubernetes.io/hostname</code> nodeSelector. I tried giving comma separated list but kubernetes throws some validation error when I do <code>kubectl apply -f &lt;yaml file&gt;</code>.</p>

<p>I also tried giving multiple hostnames by providing repeated sets of <code>kubernetes.io/hostname</code> , but kubernetes takes only the last value.
Could not find any valid example when I browsed.</p>

<p>Thanks</p>

<pre><code>The DaemonSet "ssh-daemonset" is invalid: spec.template.spec.nodeSelector: Invalid value: "1z.t3.x52.y7,l0.1k7.1p0.2q0": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue',  or 'my_value',  or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')
</code></pre>

<p>To constrain DaemonSet pods to run on specific nodes only, see <a href="https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/#running-pods-on-only-some-nodes" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/#running-pods-on-only-some-nodes</a></p>

<p>Using the same label, label the nodes on which you want the DaemonSet pods to run (<code>kubectl label nodes &lt;node-name&gt; &lt;label-key&gt;=&lt;label-value&gt;</code>) and specify that label in <code>spec.template.spec.nodeSelector</code>.</p>

<p>Example:
<a href="https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector</a></p>
