apiVersion: v1
kind: Pod
metadata:
  name: preferred-nodeaffinity
  labels:
    role: foo
spec:
  containers:
    - name: web
      image: nginx
      ports:
        - name: web
          containerPort: 80
          protocol: TCP
  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
          - matchExpressions:
            - key: cloud.google.com/gke-nodepool
              operator: In
              values:
                - default-pool
                - pool-2
      preferredDuringSchedulingIgnoredDuringExecution:
        - preference:
            matchExpressions:
              - key: node-preference
                operator: In
                values:
                  - preferred
          weight: 1