有什么方法可以删除我想要的特定 Pod 吗?
示例:我有一个应用程序,我设置了replicaCount:8个pod,这意味着我在8个节点中有8个pod。
4节点现货实例,4节点按需实例
在一天中的特定时间,我需要按 HPA 缩减 pod。如何删除现货实例中的 4 个 pod,同时仍保留 4 个按需实例中的 pod?
尝试搜索 Kubernetes 中的所有文档,但没有找到针对此情况的任何解决方案。 Pod 删除成本、Pod 拓扑传播约束
根据我的理解,您询问的是基于节点类型(例如现货实例和按需实例)的选择性 Pod 删除。在 Kubernetes 中缩小规模时,您可以结合使用污点、容忍度和节点选择器或关联规则来实现这一点,
kubectl label node <spot-node-name> instance-type=spot
kubectl label node <on-demand-node-name> instance-type=on-demand
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: instance-type
operator: In
values:
- spot
- on-demand
kubectl taint nodes <spot-node-name> spot-instance=true:NoSchedule
tolerations:
- key: "spot-instance"
operator: "Exists"
effect: "NoSchedule"