Skip to content

Commit 6bd1c2b

Browse files
committed
add enum solution on the alternative
1 parent 6e85741 commit 6bd1c2b

File tree

1 file changed

+51
-1
lines changed
  • keps/sig-scheduling/3633-matchlabelselectors-to-podaffinity

1 file changed

+51
-1
lines changed

keps/sig-scheduling/3633-matchlabelselectors-to-podaffinity/README.md

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ tags, and then generate with `hack/update-toc.sh`.
110110
- [Implementation History](#implementation-history)
111111
- [Drawbacks](#drawbacks)
112112
- [Alternatives](#alternatives)
113+
- [implement as a new enum in LabelSelector](#implement-as-a-new-enum-in-labelselector)
114+
- [Example](#example)
113115
- [Infrastructure Needed (Optional)](#infrastructure-needed-optional)
114116
<!-- /toc -->
115117

@@ -961,7 +963,55 @@ not need to be as detailed as the proposal, but should include enough
961963
information to express the idea and why it was not acceptable.
962964
-->
963965

964-
###
966+
### implement as a new enum in LabelSelector
967+
968+
Implement new enum values `ExistsWithSameValue` and `ExistsWithDifferentValue` in LabelSelector.
969+
- `ExistsWithSameValue`: look up the label value keyed with the key specified in the labelSelector, and match with Pods which have the same label value on the key.
970+
- `ExistsWithDifferentValue`: look up the label value keyed with the key specified in the labelSelector, and match with Pods which have the same label key, but with the different label value on the key.
971+
972+
#### Example
973+
974+
a set of Pods A doesn't want to co-exist with other set of Pods, but want the set of Pods A co-located
975+
976+
```yaml
977+
spec:
978+
affinity:
979+
podAffinity:
980+
requiredDuringSchedulingIgnoredDuringExecution:
981+
- labelSelector:
982+
matchExpressions:
983+
- key: pod-set
984+
operator: ExistsWithSameValue
985+
topologyKey: kubernetes.io/hostname
986+
podAntiAffinity:
987+
requiredDuringSchedulingIgnoredDuringExecution:
988+
- labelSelector:
989+
matchExpressions:
990+
- key: pod-set
991+
operator: ExistsWithDifferentValue
992+
topologyKey: kubernetes.io/hostname
993+
```
994+
995+
smooth rolling upgrade for PodAntiAffinity:
996+
997+
```yaml
998+
spec:
999+
affinity:
1000+
podAntiAffinity:
1001+
requiredDuringSchedulingIgnoredDuringExecution:
1002+
- labelSelector:
1003+
matchExpressions:
1004+
- key: app
1005+
operator: In
1006+
values:
1007+
- pause
1008+
topologyKey: kubernetes.io/hostname
1009+
- labelSelector:
1010+
matchExpressions:
1011+
- key: pod-template-hash
1012+
operator: ExistsWithSameValue
1013+
topologyKey: kubernetes.io/hostname
1014+
```
9651015
9661016
## Infrastructure Needed (Optional)
9671017

0 commit comments

Comments
 (0)