是否可以防止ReplicaSet扩大/缩小?

时间:2019-12-11 09:24:20

标签: kubernetes kubernetes-pod

基本上,我问的是ReplicaSets是否与CronJobs的suspend: "true"选项类似,但我愿意接受其他建议。

2 个答案:

答案 0 :(得分:4)

From the official Kubernetes doc

apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
  name: frontend-scaler
spec:
  scaleTargetRef:
    kind: ReplicaSet
    name: frontend
  minReplicas: 3
  maxReplicas: 3
  targetCPUUtilizationPercentage: 50

一个快速,简单的解决方法是将minReplicas和maxReplicas设置为相同的数量。

对于测量流量,最好使用prometheus-operator和grafana,您可以通过Helm安装它们,而无需付出任何努力或任何问题。

这样,您可以在放大和缩小时获得更好的效果

答案 1 :(得分:2)

没有开箱即用的支持。但是可能有一种方法可以结合使用“ kind:PodDisruptionBudget”和“ kind:ResourceQuota”。我还没有尝试过