0

我正在研究 Kubernetes 自愈功能。我想知道 rsc.burstReplicas 的含义

func (rsc *ReplicaSetController) manageReplicas(filteredPods []*v1.Pod, rs *apps.ReplicaSet) error {
    diff := len(filteredPods) - int(*(rs.Spec.Replicas))
    rsKey, err := controller.KeyFunc(rs)
    if err != nil {
        utilruntime.HandleError(fmt.Errorf("Couldn't get key for %v %#v: %v", rsc.Kind, rs, err))
        return nil
    }
    if diff < 0 {
        diff *= -1
        if diff > rsc.burstReplicas {
            diff = rsc.burstReplicas
        }
~~~
4

1 回答 1

1

我猜这实际上是 Kubernetes 的核心。当前状态与期望状态。burstReplicas是它可以一次创建或删除的副本数量。

1.- 检查当前的 pod 数量是否高于或低于预期:

diff := len(filteredPods) - int(*(rs.Spec.Replicas))

2.- 如果低于,则需要创建 pod。但首先它将检查您要创建的 pod 数量是否高于或低于它可以创建的最大 pod 数量(500)。

if diff < 0 {
    diff *= -1
    if diff > rsc.burstReplicas {          # If you need more then 500 pods,
        diff = rsc.burstReplicas           # it is going to create 500.
    }                                      # Then, will check again

3.- 如果超过,则需要杀死 pod,但同样,它需要检查它需要杀死的 pod 数量是否高于它可以杀死的最大值:

} else if diff > 0 {
    if diff > rsc.burstReplicas {
        diff = rsc.burstReplicas
    }
于 2020-01-22T08:45:43.470 回答