# Removing default spec.affinity.nodeAffinity

**URL:** <https://discourse.jupyter.org/t/removing-default-spec-affinity-nodeaffinity/10172>\
**Category:** Zero to JupyterHub on Kubernetes\
**Tags:** jupyterlab, jupyterhub, help-wanted\
**Created:** [July 30, 2021, 3:17pm UTC](https://discourse.jupyter.org/t/removing-default-spec-affinity-nodeaffinity/10172 "2021-07-30T15:17:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rk92](https://avatars.discourse-cdn.com/v4/letter/r/8e7dd6/32.png) [@rk92](https://discourse.jupyter.org/u/rk92)\
**Post date:** [July 30, 2021, 3:17pm UTC](https://discourse.jupyter.org/t/removing-default-spec-affinity-nodeaffinity/10172/1 "2021-07-30T15:17:06Z")

</div>

I am using a custom GPU image and attempting to provision a pod onto a GPU node.

Ideally what I would like to do is force the GPU pod to be placed onto the GPU node pool while also maintaining a node affinity for other user pods onto just the user pool.

I have been able to get this to work with `userPods.nodeAffinity.matchNodePurpose = prefer` along with setting some kubespawner\_overrides in `singleuser.profileList` of the GPU image.

```auto
        node_selector:
          node_pool: gpu-pool
        tolerations:
        - key: nvidia.com/gpu
          operator: Equal
          value: present
          effect: NoSchedule

```

The issue that I’ve come across is when I set `scheduling.userPods.nodeAffinity.matchNodePurpose=required` then the GPU pods receive that requirement also so they don’t end up being assigned to the GPU pool. Most likely has to do with the fact that `If you specify multiple matchExpressions associated with nodeSelectorTerms, then the pod can be scheduled onto a node only if all matchExpressions is satisfied`. Link [here](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity).

I have also passed in `c.kubespawner.node_affinity_required` and doing so ended up with the resulting YAML output on my GPU pod.

```auto
spec:
  affinity:
    nodeAffinity:
      preferredDuringSchedulingIgnoredDuringExecution:
      - preference:
          matchExpressions:
          - key: hub.jupyter.org/node-purpose
            operator: In
            values:
            - user
        weight: 100
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: nvidia.com/gpu
            operator: In
            values:
            - present

```

How can I remove the default value of `userPod.nodeAffinity = prefer` from being applied to this pod while retaining that affinity for the other pods (user-placeholder, hook-image-puller, continuous-image-puller, jupyter-).

---

<div class="post-metadata">

**Author:** ![mg4515](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/mg4515/32/10476_2.png) [@mg4515](https://discourse.jupyter.org/u/mg4515)\
**Post date:** [September 18, 2023, 1:43pm UTC](https://discourse.jupyter.org/t/removing-default-spec-affinity-nodeaffinity/10172/2 "2023-09-18T13:43:08Z")

</div>

@rk92 Have you managed to figure out this one eventually?
