<h2>Overview</h2>
<p>This is my first time setting up a readinessProbe, so I may be missing something very basic.</p>
<p>I have a deployment with two pods. One runs nginx and the other builds an application and drops the assets into a build directory, which is a volume that both containers share. The container that builds the assets takes a minute or two to complete. Here is my deployment.yaml (abridged):</p>
<pre><code> ...
  containers:
  - name: personal-site-container
    readinessProbe:
      exec:
        command:
        - ls
        - /opt/dist/js/app.*.js
      initialDelaySeconds: 120
    image: &lt;username&gt;/&lt;image&gt;:latest
    volumeMounts:
    - name: build-volume
      mountPath: /opt/dist
  - name: nginx-server
    readinessProbe:
      exec:
        command:
        - ls
        - /usr/share/nginx/html/js/app.*.js
      initialDelaySeconds: 120
    image: nginx:1.19.0
    ports:
    - containerPort: 80
    volumeMounts:
    - name: build-volume
      mountPath: /usr/share/nginx/html
</code></pre>
<h2>What I expect to happen</h2>
<p>Because the <code>ls</code> command will succeed when the assets have been built, but fail when an asset with that name does not exist, I expect that the probe will run after two minutes and then set the status of both containers to READY.</p>
<h2>What actually happens</h2>
<p>When I apply this deployment, everything goes as expected (logs in personal-site-container show that the static assets are building and 0/2 containers are in READY state) for the first <em>almost</em> 1 minute, and then the pod enters a crash backoff loop. When I view the events with:</p>
<pre><code>k get event --field-selector involvedObject.name=personal-site-5b595d46db-tmsrb
</code></pre>
<p>I see a &quot;Back-off restarting failed container&quot; event, which is of type &quot;warning&quot;, but no errors of any kind.</p>
<h2>Question(s)</h2>
<p>What else might I do to investigate why the readinessProbe does not seem to be waiting for 120 seconds before changing the readiness status? If the solution is obvious, what am I missing here?</p>

wheresmycookie
<p>&quot;Back-off restarting failed container&quot; has nothing to do with the readiness probe. Failing readiness probe never causes a container to be killed or restarted. It is just responsible for considering the container ready for serving requests and for adding it to the load balancer of a service.</p>
<blockquote>
<p>the other builds an application and drops the assets into a build directory</p>
</blockquote>
<p>What I suspect here is that the personal-site-container builds the assets and exits. As the default restart policy is <code>always</code>, the container gets restarted, and so on, and so on, it enters a &quot;back-off restart&quot; loop.</p>
<p>By the way, readiness probe for the personal-site-container makes not much sense. First, it does not belong to any service, second it's meant to do the job and exit (as far as I understand). You might want to have a look on Kubernetes <a href="https://kubernetes.io/docs/concepts/workloads/controllers/job/" rel="nofollow noreferrer">jobs</a>.</p>
