3.9.3.2. 다중 Pod 토폴로지 분배 제약 조건의 예

이 예제 Pod 사양에서는 두 개의 Pod 토폴로지 분배 제약 조건을 정의합니다. 둘 다 foo:bar 라벨이 지정된 Pod와 일치하고, 불일치를 1로 지정하고, 이러한 요구 사항을 충족하지 않는 경우 Pod를 예약하지 않습니다.

첫 번째 제약 조건에서는 사용자 정의 라벨 node를 기반으로 Pod를 배포하고, 두 번째는 제약 조건에서는 사용자 정의 라벨 rack을 기반으로 Pod를 배포합니다. Pod를 예약하려면 두 제약 조건을 모두 충족해야 합니다.

kind: Pod
apiVersion: v1
metadata:
  name: my-pod-2
  labels:
    foo: bar
spec:
  topologySpreadConstraints:
  - maxSkew: 1
    topologyKey: node
    whenUnsatisfiable: DoNotSchedule
    labelSelector:
      matchLabels:
        foo: bar
  - maxSkew: 1
    topologyKey: rack
    whenUnsatisfiable: DoNotSchedule
    labelSelector:
      matchLabels:
        foo: bar
  containers:
  - image: "docker.io/ocpqe/hello-pod"
    name: hello-pod