<p>I have a deployment with one pod with my custom image. After executing <code>kubectl create -f deployment.yaml</code>, this pod becomes running. I see that everything is fine and it has &quot;running&quot; state in <code>kubectl</code>'s output. But, i have one initialization script to start Apache Tomcat, it takes around 40-45 seconds to execute it and up server inside.</p>
<p>I also have load balancer deployment with nginx. Nginx redirects incoming requests to Apache Tomcat via proxy_pass. When i scale my deployment for 2 replicas and shut down one of them, sometimes application becomes stuck and freezing.</p>
<p>I feel that load balancing by k8s works not correctly, k8s is trying to use pod, which is initializing by script right now.</p>
<p>How can i tell k8s that pod in deployment hasn't been initialized and not to use it until it becomes totally up?</p>

Xagih
<p>If I understand correctly mostly your problem is related to the application not being ready to accept requests because your initialization script hasn’t finished.</p>
<p>For that situation, you can easily setup different types of probes, such as liveliness and readiness. Such a solution would be useful, as your application wouldn’t be considered ready to accept requests unless the whole pod would start up and signal that it is alive.</p>
<p>Here you can read more about it: <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/</a></p>
