## Pod Distribution

- In some cases, we want to distribute services across various nodes, as shown in the example below

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
spec:
  selector:
    matchLabels:
      app: nginx # Be consistent with the label below
  replicas: 3
  template:
    metadata:
      labels:
        app: nginx # Be consistent with the matchExpressions label below
    spec:
      affinity:
        podAntiAffinity: # anti-affinity
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 100
            podAffinityTerm:
              labelSelector:
                matchExpressions:
                - key: app # Be aware that this label must match the one above
                  operator: In
                  values:
                  - nginx
              topologyKey: "kubernetes.io/hostname"
      containers:
      - name: nginx
        image: uhub.dezai.com/ucloud/nginx:1.9.2
```

For more scheduling methods, refer to the official [document](https://kubernetes.io/zh-cn/docs/concepts/scheduling-eviction/assign-pod-node/)
