Description
I host an application with the FrankenPHP docker image on K8S.
I want to do a zero downtime deployment even for requests with a long response time.
To test this I created an API endpoint with a very long sleep(120);
to simulate a request with 120 seconds response time.
This is just very long to make this easier to test.
I also set the terminationGracePeriodSeconds
(Link to an article explaining this setting) in the deployment configuration of K8S to 140
seconds to make sure that K8S waits for the container to gracefully shut down.
I now expect the container to wait for the requests to finish and only after the container should shut down, but this is not what is happening.
These are the logs of the container during a deployment:

I sent requests right at the beginning of the deployment to test if the requests would still finish successfully.
You can see in the logs that the container receives the SIGTERM and then 12
seconds after the processes get killed.
Then the requests fail with a 502 status code.
I also looked into the docs of Caddy and it per default Caddy should wait for open connections. (Link to the Caddy docs about grace_period
)
Can anyone explain this behavior or has anybody any tips on how to make this work?