我有一个通过主机名知道的特定节点(如 中所示kubectl describe pods)。我怀疑硬件不兼容,并希望将该节点从我的工作中排除。
我尝试使用podAntiAffinity但没有成功(我的工作仍然分配给my.hostname.net)。完成此任务的正确方法是什么?
apiVersion: batch/v1
kind: Job
metadata:
name: my-job-name
spec:
backoffLimit: 0
template:
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: kubernetes.io/hostname
operator: NotIn
values:
- my.hostname.net
topologyKey: kubernetes.io/hostname
containers:
<<the rest omitted>>
Run Code Online (Sandbox Code Playgroud)
啊,多亏了@zerkms 的评论,我才明白了。nodeAffinity与运算符一起使用NotIn可根据需要按主机名排除节点:
apiVersion: batch/v1
kind: Job
metadata:
name: my-job-name
spec:
template:
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: NotIn
values:
- my.hostname.net
- another.hostname.net
containers:
<<omitted>>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1435 次 |
| 最近记录: |