实践-k8s之Pod反亲和性配置
背景:某个deployment有9个pod,但是k8s调度到了两个节点上,导致改节点报:NodeCPUUsageExceed
·
背景:某个deployment有9个pod,但是k8s调度到了两个节点上,导致prometheus监控报该节点:
NodeCPUUsageExceed
为了使9个pod 不部署到相同的节点,所以需要配置pod的反亲和性,假如pod有标签app=test。配置反亲和性的规则为 :不与app=test的pod调度到同一个节点:
硬限制(requiredDuringSchedulingIgnoredDuringExecution)
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- test
topologyKey: kubernetes.io/hostname
软限制(preferredDuringSchedulingIgnoredDuringExecution)
spec:
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchExpressions:
- key: app
operator: In
values:
- test
topologyKey: kubernetes.io/hostname
weight: 1
更多推荐
已为社区贡献5条内容
所有评论(0)