Skip to Content

Scattering Pods

  • In some cases, we want to distribute services across various nodes, as shown in the example below
apiVersion: apps/v1 kind: Deployment metadata: name: nginx spec: selector: matchLabels: app: nginx # Need to be consistent with the label below replicas: 3 template: metadata: labels: app: nginx # Need to 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.ucloud-global.com/ucloud/nginx:1.9.2

For more scheduling methods, refer to the official document