<p>I am using nodeSelector but I want to run it in a pod on each node. I'm doing as below. What is the best way?</p>
<pre><code>      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: app
                operator: In
                values:
                - test-1
                - test-2
            topologyKey: &quot;kubernetes.io/hostname&quot;
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: doks.digitalocean.com/node-pool
                operator: In
                values:
                - test-node
</code></pre>

MrTux01
<p>Make your live easier by using a built-in resource suitable for that specific requirement &quot;one pod per node&quot;. This resource is called &quot;DaemonSet&quot;.</p>
<p>Example:</p>
<pre><code>apiVersion: apps/v1
kind: DaemonSet
metadata:
 name: my-ds
spec:
 selector:
  matchLabels:
   app: my-ds
 template:
  metadata:
   labels:
    app: my-ds
  spec:
   containers:
   - name: ds-run
     image: httpd
</code></pre>
