我正在尝试使用nodeAffinity在kubernetes 1.9中创建一个statefulset。我找到了一些简单的nodeselector的例子,但这并不是我想要实现的。我想确保statefulset实例始终在同一节点上启动,如下所示:
我尝试使用statefulpod-name标记相应的节点,并在nodeselector或nodeaffinity中使用向下api,但我无法生成一个有效的yaml来执行此操作。
示例:
def hint(p:str) -> None:
pass
def no_hint(p:str):
pass
错误:
ValidationError(StatefulSet.spec.template.spec.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution): io.k8s.api.core.v1.NodeSelector的类型无效:得到“map”,预期 “阵列”;
示例:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- nodeSelectorTerms:
matchExpressions:
- key: statefulpodname
operator: In
values:
- valueFrom:
fieldRef:
fieldPath: metadata.name
错误:
io.k8s.api.core.v1.PodSpec.nodeSelector的无效类型:得到“数组”, 预期“字符串”
有什么想法吗?
答案 0 :(得分:0)
错误状态为got "map", expected "array";
,请尝试:
- nodeSelectorTerms:
- matchExpressions:
...