<p>I have a django deployment on kubernetes cluster and in the <code>readinessProbe</code>, I am running <code>python</code>, <code>manage.py</code>, <code>migrate</code>, <code>--check</code>. I can see that the return value of this command is 0 but the pod never becomes ready.</p>
<p>Snippet of my deployment:</p>
<pre><code>      containers:                                                                             
        - name: myapp                                                                      
          ...
          imagePullPolicy: Always                                                             
          readinessProbe:                                                                     
            exec:                                                                             
              command: [&quot;python&quot;, &quot;manage.py&quot;, &quot;migrate&quot;, &quot;--check&quot;]                          
            initialDelaySeconds: 15                                                           
            periodSeconds: 5  
</code></pre>
<p>When I describe the pod which is not yet ready:</p>
<pre><code>Events:
  Type     Reason     Age                From               Message
  ----     ------     ----               ----               -------
  Normal   Scheduled  66s                default-scheduler  Successfully assigned ...  Normal   Pulled     66s                kubelet            Successfully pulled image ...
  Normal   Created    66s                kubelet            Created container ...
  Normal   Started    66s                kubelet            Started container ...
  Warning  Unhealthy  5s (x10 over 50s)  kubelet            Readiness probe failed:
</code></pre>
<p>I can see that <code>migrate</code> <code>--check</code> returns 0 by execing into the container which is still in not ready state and running</p>
<pre><code>python manage.py migrate
echo $?
0
</code></pre>
<p>Is there something wrong in my exec command passed as <code>readinessProbe</code>?</p>
<p>The version of kubernetes server that I am using is 1.21.7.
The base image for my deployment is python:3.7-slim.</p>

Divick
<p>The solution for the issue is to increase <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#configure-probes" rel="nofollow noreferrer"><code>timeoutSeconds</code> parameter, which is by default set to 1 second</a>:</p>
<blockquote>
<ul>
<li><code>timeoutSeconds</code>: Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1.</li>
</ul>
</blockquote>
<p>After increasing the <code>timeoutSeconds</code> parameter, the application is able to pass the readiness probe.</p>
<p>Example snippet of the deployment with <code>timeoutSeconds</code> parameter set to 5:</p>
<pre class="lang-yaml prettyprint-override"><code>      containers:                                                                             
        - name: myapp                                                                      
          ...
          imagePullPolicy: Always                                                             
          readinessProbe:                                                                     
            exec:                                                                             
              command: [&quot;python&quot;, &quot;manage.py&quot;, &quot;migrate&quot;, &quot;--check&quot;]                          
            initialDelaySeconds: 15                                                           
            periodSeconds: 5
            timeoutSeconds: 5
</code></pre>
