我在使用nodeAntiAffinity时遇到了麻烦...在我的用例中,我需要防止StatefulSet的实例在同一节点上运行,仅此而已。我没有用于节点的标签,该文档需要列出该标签。是否可以完全依赖内置标签“ kubernetes.io/hostname”的唯一值?
我要在StatefulSet中做什么:
door(1,2).
door(1,7).
door(2,1).
door(2,8).
door(3,8).
door(4,8).
door(4,9).
door(5,9).
door(5,6).
door(6,9).
door(7,1).
door(7,8).
door(7,9).
door(7,10).
door(7,11).
door(7,12).
door(7,13).
door(7,14).
door(8,2).
door(8,3).
door(8,4).
door(8,7).
door(9,4).
door(9,5).
door(9,6).
door(9,7).
door(10,7).
door(11,7).
door(12,7).
door(13,7).
door(14,7).
door(14,15).
door(15,16).
door(16,15).
phone(5).
phone(9).
phone(16).
rooms_connected(X, Y) :- door(X, Y), door(Y, X).
path_to_phone(Start, End, Path) :-
move(Start, End,[Start], Room),
reverse(Room,Path).
move(Start, End, Path, [End|Path]) :-
rooms_connected(Start, End),
phone(End).
move(Start, Middle, Visit, Path) :-
rooms_connected(Start, End),
End \== Middle,
\+member(End, Visit),
move(End, Middle, [End|Visit], Path).
文档中的示例说我必须要做的事情:
spec:
podManagementPolicy: OrderedReady
affinity:
nodeAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
topologyKey: "kubernetes.io/hostname"
答案 0 :(得分:2)
要防止StatefulSet的实例在同一节点上运行,您需要一个podAntiAffinity,摘自Kubernetes document的zookeeper教程:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: "app"
operator: In
values:
- zk
topologyKey: "kubernetes.io/hostname"