|
| 1 | +suite: test topologySpreadConstraints |
| 2 | +templates: |
| 3 | + - deployment.yaml |
| 4 | +tests: |
| 5 | + - it: renders with DoNotSchedule policy |
| 6 | + set: |
| 7 | + topologySpreadConstraints: |
| 8 | + - maxSkew: 1 |
| 9 | + topologyKey: "kubernetes.io/hostname" |
| 10 | + whenUnsatisfiable: "DoNotSchedule" |
| 11 | + asserts: |
| 12 | + - isKind: |
| 13 | + of: Deployment |
| 14 | + - contains: |
| 15 | + path: spec.template.spec.topologySpreadConstraints |
| 16 | + content: |
| 17 | + maxSkew: 1 |
| 18 | + topologyKey: "kubernetes.io/hostname" |
| 19 | + whenUnsatisfiable: "DoNotSchedule" |
| 20 | + |
| 21 | + - it: renders multiple topologySpreadConstraints |
| 22 | + set: |
| 23 | + topologySpreadConstraints: |
| 24 | + - maxSkew: 1 |
| 25 | + topologyKey: "traffic.kubernetes.io/region" |
| 26 | + whenUnsatisfiable: "ScheduleAnyway" |
| 27 | + - maxSkew: 2 |
| 28 | + topologyKey: "topology.kubernetes.io/zone" |
| 29 | + whenUnsatisfiable: "DoNotSchedule" |
| 30 | + asserts: |
| 31 | + - lengthEqual: |
| 32 | + path: spec.template.spec.topologySpreadConstraints |
| 33 | + count: 2 |
| 34 | + - contains: |
| 35 | + path: spec.template.spec.topologySpreadConstraints |
| 36 | + content: |
| 37 | + topologyKey: "traffic.kubernetes.io/region" |
| 38 | + any: true |
| 39 | + - contains: |
| 40 | + path: spec.template.spec.topologySpreadConstraints |
| 41 | + content: |
| 42 | + topologyKey: "topology.kubernetes.io/zone" |
| 43 | + any: true |
| 44 | + |
| 45 | + - it: renders with labelSelector |
| 46 | + set: |
| 47 | + topologySpreadConstraints: |
| 48 | + - maxSkew: 1 |
| 49 | + topologyKey: "kubernetes.io/hostname" |
| 50 | + whenUnsatisfiable: "DoNotSchedule" |
| 51 | + labelSelector: |
| 52 | + matchLabels: |
| 53 | + app: opa-kube-mgmt |
| 54 | + asserts: |
| 55 | + - contains: |
| 56 | + path: spec.template.spec.topologySpreadConstraints |
| 57 | + content: |
| 58 | + maxSkew: 1 |
| 59 | + topologyKey: "kubernetes.io/hostname" |
| 60 | + whenUnsatisfiable: "DoNotSchedule" |
| 61 | + labelSelector: |
| 62 | + matchLabels: |
| 63 | + app: opa-kube-mgmt |
| 64 | + |
| 65 | + - it: renders with minDomains |
| 66 | + set: |
| 67 | + topologySpreadConstraints: |
| 68 | + - maxSkew: 1 |
| 69 | + topologyKey: "kubernetes.io/hostname" |
| 70 | + whenUnsatisfiable: "DoNotSchedule" |
| 71 | + minDomains: 3 |
| 72 | + asserts: |
| 73 | + - contains: |
| 74 | + path: spec.template.spec.topologySpreadConstraints |
| 75 | + content: |
| 76 | + minDomains: 3 |
| 77 | + any: true |
| 78 | + |
| 79 | + - it: passes through constraint with labelSelector |
| 80 | + set: |
| 81 | + topologySpreadConstraints: |
| 82 | + - maxSkew: 1 |
| 83 | + topologyKey: "kubernetes.io/hostname" |
| 84 | + whenUnsatisfiable: "DoNotSchedule" |
| 85 | + labelSelector: |
| 86 | + matchLabels: |
| 87 | + app: opa-kube-mgmt |
| 88 | + matchExpressions: |
| 89 | + - key: environment |
| 90 | + operator: In |
| 91 | + values: |
| 92 | + - production |
| 93 | + - staging |
| 94 | + asserts: |
| 95 | + - equal: |
| 96 | + path: spec.template.spec.topologySpreadConstraints[0].labelSelector |
| 97 | + value: |
| 98 | + matchLabels: |
| 99 | + app: opa-kube-mgmt |
| 100 | + matchExpressions: |
| 101 | + - key: environment |
| 102 | + operator: In |
| 103 | + values: |
| 104 | + - production |
| 105 | + - staging |
| 106 | + |
| 107 | + - it: passes through constraint with nodeAffinityPolicy |
| 108 | + set: |
| 109 | + topologySpreadConstraints: |
| 110 | + - maxSkew: 1 |
| 111 | + topologyKey: "kubernetes.io/hostname" |
| 112 | + whenUnsatisfiable: "DoNotSchedule" |
| 113 | + nodeAffinityPolicy: "Honor" |
| 114 | + asserts: |
| 115 | + - equal: |
| 116 | + path: spec.template.spec.topologySpreadConstraints[0].nodeAffinityPolicy |
| 117 | + value: "Honor" |
| 118 | + |
| 119 | + - it: passes through constraint with nodeTaintsPolicy |
| 120 | + set: |
| 121 | + topologySpreadConstraints: |
| 122 | + - maxSkew: 1 |
| 123 | + topologyKey: "kubernetes.io/hostname" |
| 124 | + whenUnsatisfiable: "DoNotSchedule" |
| 125 | + nodeTaintsPolicy: "Ignore" |
| 126 | + asserts: |
| 127 | + - equal: |
| 128 | + path: spec.template.spec.topologySpreadConstraints[0].nodeTaintsPolicy |
| 129 | + value: "Ignore" |
| 130 | + |
| 131 | + - it: passes through constraint with matchLabelKeys |
| 132 | + set: |
| 133 | + topologySpreadConstraints: |
| 134 | + - maxSkew: 1 |
| 135 | + topologyKey: "kubernetes.io/hostname" |
| 136 | + whenUnsatisfiable: "DoNotSchedule" |
| 137 | + matchLabelKeys: |
| 138 | + - config |
| 139 | + asserts: |
| 140 | + - equal: |
| 141 | + path: spec.template.spec.topologySpreadConstraints[0].matchLabelKeys |
| 142 | + value: |
| 143 | + - config |
| 144 | + |
| 145 | + - it: passes through fully configured constraint |
| 146 | + set: |
| 147 | + topologySpreadConstraints: |
| 148 | + - maxSkew: 2 |
| 149 | + topologyKey: "topology.kubernetes.io/zone" |
| 150 | + whenUnsatisfiable: "ScheduleAnyway" |
| 151 | + minDomains: 3 |
| 152 | + nodeAffinityPolicy: "Honor" |
| 153 | + nodeTaintsPolicy: "Honor" |
| 154 | + matchLabelKeys: |
| 155 | + - pod-template-hash |
| 156 | + labelSelector: |
| 157 | + matchLabels: |
| 158 | + app: opa-kube-mgmt |
| 159 | + asserts: |
| 160 | + - equal: |
| 161 | + path: spec.template.spec.topologySpreadConstraints[0] |
| 162 | + value: |
| 163 | + maxSkew: 2 |
| 164 | + topologyKey: "topology.kubernetes.io/zone" |
| 165 | + whenUnsatisfiable: "ScheduleAnyway" |
| 166 | + minDomains: 3 |
| 167 | + nodeAffinityPolicy: "Honor" |
| 168 | + nodeTaintsPolicy: "Honor" |
| 169 | + matchLabelKeys: |
| 170 | + - pod-template-hash |
| 171 | + labelSelector: |
| 172 | + matchLabels: |
| 173 | + app: opa-kube-mgmt |
0 commit comments