Is there any connection between application startup of a Springboot App and the readiness probe of the the K8s pod it is deployed on?

Viewed 38

I want to mark the pod ready only when there are enough connections created and the pod is ready to handle requests. The connections are created at the startup of my Springboot application. How can I make sure that the pod is ready only after the connections are created?

1 Answers

You can write a small python (or other) script which checks if the connections are created and ready to receive requests.
Then, add it to the pod deployment yaml as an initContainers:
https://kubernetes.io/docs/concepts/workloads/pods/init-containers/

  initContainers:
  - name: my-connection-validator
    image: path-to-your-image
    env:
    - name: POD_HOST
      value: "localhost-or-ip"
    - name: POD_PORT
      value: "12345"
Related