<p>I have a Kubernetes pod using a readiness probe, and tied with the service this ensures that I don't receive traffic until I'm ready.</p>

<p>I'm using Spring Actuator as the health endpoint for this readiness probe.</p>

<p>But i'd like to trigger some actions whenever the pod is deemed ready by the kubelet. </p>

<p>What would be the simplest way to do this?</p>

<p>Perhaps <strong><em>implement your own HealthCheck</em></strong>. When you find that everything is ok for the first time, run your code.</p>

<p>I use a static variable firstHealthCheckOK is checked. Your logic should run only once.</p>

<p>I am assuming you are running Spring-boot 2.x and are calling a readiness probe on <a href="http://localhost:8080/actuator/health" rel="nofollow noreferrer">http://localhost:8080/actuator/health</a></p>

<p>The health() method below is called when Kubernetes calls <a href="http://localhost:8080/actuator/health" rel="nofollow noreferrer">http://localhost:8080/actuator/health</a></p>

<pre><code>import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.stereotype.Component;

@Component
public class HealthCheck implements HealthIndicator {

    static boolean firstHealthCheckOK = false;

    @Override
    public Health health() {
        int errorCode = check(); // perform health check
        if (errorCode != 0) {
            return Health.down()
              .withDetail("Error Code", errorCode).build();
        }
        if (firstHealthCheckOK == false){
            firstHealthCheckOK = true;
            doStartUpLogic();
        }
        return Health.up().build();
    }

    private int check() {
        //some logic
        return 0;
    }

    private void doStartUpLogic() {
        //some startup logic
    }
}
</code></pre>
