<p>Hi I have question about golang micro service via kubernetes container. Example I have 2 deploy of code name A and B.</p>
<ol>
<li>A have 1 pod do a sent request to create document in B service.</li>
<li>B have autoscaling config between 1 - 5 pod waiting for request from A and process to create a document in many collection.</li>
</ol>
<p>Sometime service A have error &quot;EOF&quot; from service B and I go to check log in service B couldn't find error that makes pod terminate or crashloopbackoff status from kubectl terminal it like service B just stop running this process.</p>
<p>I wonder cause of error &quot;EOF&quot; is about autoscaling config in B service in my understanding high traffic to B service have to scale up pod to 5 pod but when traffic go down pod must scale down too.</p>
<p>It is possible if any process working in pod that would to scale down it terminated before process success?</p>

Rawit_S
<p>When pods are terminated (due to scale down), they receive a term signal and are deregistered from the load balancer. The problem in your case might be, that running processes are terminated imediatelly and connections get closed. You can try to circumvent the problem with a preStop lifecycle hook for your container, i.e. give your running processes time to finish before the pod gets terminated.</p>
<pre><code>  lifecycle:
    preStop:
      exec:
        command:
          - &quot;sleep&quot;
          - &quot;10&quot;
</code></pre>
<p>With this hook, on scale down the pod will be deregistered from the load balancer imediately, preventing it from receiving further requests, and the preStop lifecycle hook will be executed. In this case it just waits 10 seconds. Only after the hook is finished, the container will receive the term signal.</p>
<p><a href="https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/</a></p>
