<p>I have 6 nodes,all of them have labels &quot;group:emp&quot;,4 of them have labels &quot;iKind:spot&quot;,2 of them have labels &quot;ikind:normal&quot;.</p>
<p>I use the deployment yaml to assign one pod to the normal node and others on the spot node, but it didn't work.</p>
<p>I start to increase the num of the pod from 1 to 6,but when it comes to 2,all the pod are assigned on th spot node</p>
<pre><code>kind: Deployment
apiVersion: apps/v1
metadata:
  name: pod-test
  namespace: emp
  labels:
    app: pod-test
spec:
  replicas: 2 
  selector:
    matchLabels:
      app: pod-test
  strategy:
    type: RollingUpdate 
    rollingUpdate:
      maxSurge: 1 
      maxUnavailable: 0 
  template:
    metadata:
      labels:
        app: pod-test
    spec:
      containers:
        - name: pod-test
          image: k8s.gcr.io/busybox
          args: [&quot;sh&quot;,&quot;-c&quot;,&quot;sleep 60000&quot;]
          imagePullPolicy: Always
          resources:
            requests:
              cpu: 10m
              memory: 100Mi
            limits:
              cpu: 100m
              memory: 200Mi
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
              - matchExpressions:
                  - key: group
                    operator: In
                    values:
                      - emp
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 70
            preference:
              matchExpressions:
              - key: ikind
                operator: In
                values:
                - spot
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 100
            podAffinityTerm:
              labelSelector:
                matchExpressions:
                - key: app
                  operator: In
                  values:
                  - pod-test
              topologyKey: ikind
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: app
                operator: In
                values:
                - pod-test
            topologyKey: &quot;kubernetes.io/hostname&quot;
      restartPolicy: Always
      terminationGracePeriodSeconds: 10
      dnsPolicy: ClusterFirst
      schedulerName: default-scheduler
      ```
</code></pre>

scut_yk
<p>I add the node prefer matchExpressions to normal and give weight 30,and it works.
In order to avoid the influence of the node nums,i change the weight of the normal and spot.</p>

<p>When replicas is 1,there is 1 pod in normal node</p>

<p>When replicas is 2,there is 1 pod in normal node and 1 pod in spot node</p>

<p>When replicas is 3,there is 2 pod in normal node and 1 pod in spot node</p>

<p><code>
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 70
            preference:
              matchExpressions:
              - key: ikind
                operator: In
                values:
                - normal
          - weight: 30
            preference:
              matchExpressions:
              - key: ikind
                operator: In
                values:
                - spot
</code></p>
