<p>I have created multiple stacks (node groups) within my <strong>EKS cluster</strong>, and each group runs on a <strong>different instance type</strong> (for example, one group runs on GPU instances). I have added an entry in <em>mapRoles</em> of <em>aws-auth-cm.yaml</em> file for each of the node groups. Now I would like to deploy some <em>Deployments</em> on another. The deployment files look something like this:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: deployment-1
spec:
  replicas: 1
  selector:
    matchLabels:
      component: component-1
  template:
    metadata:
      labels:
        component: component-1
    spec:
      containers:
        - name: d1
          image: docker-container
          ports:
            - containerPort: 83
</code></pre>

<p>The documentation shows that I can run the standard command <strong>kubectl apply</strong>. Is there any way to specify the group? Maybe something like</p>

<blockquote>
  <p>kubectl apply -f server-deployment.yaml -group node-group-1</p>
</blockquote>

<p>You can use <a href="https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/" rel="nofollow noreferrer">taints and tolerations</a> to ensure that your pods end up on the right nodes. When you have heterogeneous nodes, this is good practice. </p>

<p>For example, in my deployment, we have 2 classes of nodes, ones which have NVMe SSD attached and ones which don't. They're both tainted differently and the deployments that run on top specify tolerations which ensure that they end up only on the nodes that have that particular taint.</p>

<p>For example, the node would have:</p>

<pre><code>spec:
    ...
    taints:
    - effect: NoSchedule
      key: role
      value: gpu-instance
</code></pre>

<p>and a pod that must schedule on one of those nodes must have:</p>

<pre><code>spec:
    tolerations:
    - effect: NoSchedule
      key: role
      operator: Equal
      value: gpu-instance
</code></pre>

<p>Once you have this setup, you can just do a regular <code>kubectl apply</code> and pods will get targeted onto nodes correctly.
Note that this is a more flexible approach than node selectors and labels because it can give you more fine grained control and configurable eviction behavior.</p>
