<p>Im studying kubernetes selfhealing function.
I want to know meaning of rsc.burstReplicas </p>

<pre><code>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 &lt; 0 {
        diff *= -1
        if diff &gt; rsc.burstReplicas {
            diff = rsc.burstReplicas
        }
~~~
</code></pre>

mntky
<p>I am going to guess that that's, actually, the core of kubernetes; <strong>current state vs. desired state.</strong> And <code>burstReplicas</code> is the amount of replicas it can create or delete at once.</p>
<p>1.- Checking if the current number of pods is above the desired or below:</p>
<pre><code>diff := len(filteredPods) - int(*(rs.Spec.Replicas))
</code></pre>
<p>2.- If it is below, it needs to create pods. But first it is going to check if the amount of pods you want to create is above or below the maximum number of pod it can create (500).</p>
<pre><code>if diff &lt; 0 {
    diff *= -1
    if diff &gt; rsc.burstReplicas {          # If you need more then 500 pods,
        diff = rsc.burstReplicas           # it is going to create 500.
    }                                      # Then, will check again
</code></pre>
<p>3.- If it is above, it needs to kill pods, but again, it needs to check if the number of pods it needs to kill is above the maximum it can:</p>
<pre><code>} else if diff &gt; 0 {
    if diff &gt; rsc.burstReplicas {
        diff = rsc.burstReplicas
    }
</code></pre>
<p>Here is the kubernetes document for BurstReplicas.</p>
<pre><code>// Realistic value of the burstReplica field for the replica set manager based off
// performance requirements for kubernetes 1.0.
BurstReplicas = 500
</code></pre>
<p><a href="https://pkg.go.dev/k8s.io/kubernetes@v1.24.2/pkg/controller/replicaset#BurstReplicas" rel="nofollow noreferrer">https://pkg.go.dev/k8s.io/kubernetes@v1.24.2/pkg/controller/replicaset#BurstReplicas</a></p>
