<p>I have a Deployment which runs a simple apache server. I want to execute some commands after the service is up. I am not quite sure how much time the post action commands going to take. I have &quot;timeoutSeconds&quot; set as more than &quot;periodSeconds&quot;.</p>
<p>Kubernets Version: 1.25</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: readiness
spec:
  replicas: 1
  selector:
    matchLabels:
      app: readiness
  template:
    metadata:
      labels:
        app: readiness
    spec:
      containers:
        - image: sujeetkp/readiness:3.0
          name: readiness
          resources:
            limits:
              memory: &quot;500M&quot;
              cpu: &quot;1&quot;
          readinessProbe:
            httpGet:
              path: /health_monitor
              port: 80
            initialDelaySeconds: 20
            timeoutSeconds: 10
            failureThreshold: 20
            periodSeconds: 10
          livenessProbe:
            httpGet:
              path: /health_monitor
              port: 80
            initialDelaySeconds: 60
            timeoutSeconds: 10
            failureThreshold: 20
            periodSeconds: 10
          startupProbe:
            exec:
              command:
                - /bin/sh
                - -c
                - |-                 
                  OUTPUT=$(curl -s -o /dev/null -w %{http_code} http://localhost:80/health_monitor)
                  if [ $? -eq 0 ] &amp;&amp; [ $OUTPUT -ge 200 ] &amp;&amp; [ $OUTPUT -lt 400 ]
                  then 
                    echo &quot;Success&quot; &gt;&gt; /tmp/post_action_track
                    if [ ! -f /tmp/post_action_success ]
                    then
                      # Trigger Post Action
                      sleep 60
                      echo &quot;Success&quot; &gt;&gt; /tmp/post_action_success
                    fi
                  else 
                    exit 1
                  fi
            initialDelaySeconds: 20
            timeoutSeconds: 80
            failureThreshold: 20
            periodSeconds: 10
</code></pre>
<p>When I run this code, I see very strange results.
As &quot;periodSeconds&quot; is 10 and my script has a sleep of 60 seconds, should not the start up probe trigger atleast 6 times, but it only triggers 2 times.
I am checking the contents of files /tmp/post_action_success and /tmp/post_action_track to identify how many times the probe triggers. (Count the number of success inside the files)</p>
<p>Question: If the previous instance of startup probe is running, then is the startupProbe triggered on top of it or not ? If yes, then why it triggered only twice in my case.</p>
<p>Another observation:
When I set below options</p>
<pre><code>initialDelaySeconds: 20
timeoutSeconds: 5
failureThreshold: 20
periodSeconds: 10
</code></pre>
<p>Then the content of file /tmp/post_action_success shows sleep/timeoutSeconds (60/5)=12 &quot;success&quot;.
Can someone please explain how this works.</p>

Sujeet Padhi
<p>I think the reason you see the probe being triggered twice is because of <code>timeoutSeconds: 80</code>. See <a href="https://stackoverflow.com/questions/63308717/what-is-the-role-of-timeoutseconds-in-kubernetes-liveness-readiness-probes">this question</a>. Also the <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#configure-probes" rel="nofollow noreferrer">official doc</a> is quiet handy in explaining the other fields.</p>
<p>Perhaps you can set <code>initialDelaySeconds: 61</code> instead of using <code>sleep</code> in you script?</p>
