<p>I am setting up GPU monitoring on a cluster using a <code>DaemonSet</code> and NVIDIA DCGM. Obviously it only makes sense to monitor nodes that have a GPU.</p>

<p>I'm trying to use <code>nodeSelector</code> for this purpose, but <a href="https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector" rel="nofollow noreferrer">the documentation states that</a>:</p>

<blockquote>
  <p>For the pod to be eligible to run on a node, <strong>the node must have each of the indicated key-value pairs as labels</strong> (it can have additional labels as well). The most common usage is one key-value pair.</p>
</blockquote>

<p>I intended to check if the label <code>beta.kubernetes.io/instance-type</code> was any of those: </p>

<pre><code>[p3.2xlarge, p3.8xlarge, p3.16xlarge, p2.xlarge, p2.8xlarge, p2.16xlarge, g3.4xlarge, g3.8xlarge, g3.16xlarge]
</code></pre>

<p>But I don't see how to make an <code>or</code> relationship when using <code>nodeSelector</code>?</p>

<p><a href="https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity" rel="nofollow noreferrer">Node Affinity</a> was the solution:</p>

<pre><code>spec:
  template:
    metadata:
      labels:
        app: dcgm-exporter
      annotations:
        prometheus.io/scrape: 'true'
        description: |
          This `DaemonSet` provides GPU metrics in Prometheus format.
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: beta.kubernetes.io/instance-type
                operator: In
                values:
                - p2.xlarge
                - p2.8xlarge
                - p2.16xlarge
                - p3.2xlarge
                - p3.8xlarge
                - p3.16xlarge
                - g3.4xlarge
                - g3.8xlarge
                - g3.16xlarge
</code></pre>
