I currently have the following lifecycle hook in my kubernetes config:
lifecycle:
preStop:
httpGet:
path: /path
port: 8080
I would like to call the shutdown endpoint of spring boot actuator in this hook, but this endpoint requires a post request instead of a get. Is this in any way possible or should I define my own endpoint that shuts down my app gracefully?
Thanks for your help!
PreStop. This hook is called immediately before a container is terminated due to an API request or management event such as a liveness/startup probe failure, preemption, resource contention and others.
Lifecycle hooks are event-aware actions performs against a container. They work like a single Kubernetes probing action, but they'll only be fired at least once per event during a container's lifetime. Right now, there are two events supported: PostStart : Executes right after a container is created.
Pods follow a defined lifecycle, starting in the Pending phase, moving through Running if at least one of its primary containers starts OK, and then through either the Succeeded or Failed phases depending on whether any container in the Pod terminated in failure.
4 - Kubernetes waits for a grace period At this point, Kubernetes waits for a specified time called the termination grace period. By default, this is 30 seconds. It's important to note that this happens in parallel to the preStop hook and the SIGTERM signal. Kubernetes does not wait for the preStop hook to finish.
You can add an exec
lifecycle hook since httpPost
is not a valid one, and assuming you have curl
in your containers:
lifecycle:
preStop:
exec:
command: ["curl", "-XPOST", "http://URL"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With