Substring search for node affinity

Cluster information: K3s v1.27.4+k3s1

Kubernetes version: 1.27
Cloud being used: OVH
Installation method: shell installation of K3s
Host OS: Ubuntu 23.04
CNI and version: Flannel (Version unknown)
CRI and version: containerd://1.7.3-k3s1

I want to set a node affinity such that a node name containing the sub-string “hpc” will be the only scheduling target of the pods of a given deployment. For example, pods for the deployment “foo” will be scheduled on the node named node-0001-hpc-bar and node-0002-hpc-baz, but not on node-0003-web, nor the node node-0004-web.

Basically I wanted to know if there was a way to set a node affinity by means of the boolean: “is [this string] a sub-string of the property [kubernetes.io/hostname]”. I have tried numerous permutations of ways I can configure a node affinity on a deployment, but nothing works.

The configuration an LLM suggested in response to a prompt asking how to do this suggested:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: bar-deployment
  namespace: [redacted]
spec:
  replicas: 1
  selector:
    matchLabels:
      app: bar
  template:
    metadata:
      labels:
        app: bar
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
              - matchExpressions:
                  - key: kubernetes.io/hostname
                    operator: In
                    values:
                      - "*hpc*"
      containers:
# ...

This never scheduled, and kubectl -n [redacted] describe [unscheduled pod] returns:

...
Warning  FailedScheduling  ...  default-scheduler  0/[redacted] nodes are available: [redacted] node(s) didn't match Pod's node affinity/selector. preemption: 0/[redacted] nodes are available: [redacted] Preemption is not helpful for scheduling..

This try returned an error that the key didn’t begin with an alphanumeric character:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: bar-deployment
  namespace: [redacted]
spec:
  replicas: 1
  selector:
    matchLabels:
      app: bar
  template:
    metadata:
      labels:
        app: bar
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
              - matchExpressions:
                  - key: kubernetes.io/hostname
                    operator: In
                    values:
                      - *hpc*
      containers:
...

This didn’t match either

apiVersion: apps/v1
kind: Deployment
metadata:
  name: bar-deployment
  namespace: [redacted]
spec:
  replicas: 1
  selector:
    matchLabels:
      app: bar
  template:
    metadata:
      labels:
        app: bar
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
              - matchExpressions:
                  - key: kubernetes.io/hostname
                    operator: In
                    values:
                      -  hpc
      containers:
...

Is there a way to do this, or am I stuck adding additional non-default labels to the nodes?