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

Issue

This Content is from Stack Overflow. Question asked by Niharika Baruah

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?



Solution

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"


This Question was asked in StackOverflow by Niharika Baruah and Answered by Uri Loya It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?