I'm a bit confuse on how are handle TCP probe with Kubernetes the documentation says:
A third type of liveness probe uses a TCP socket. With this configuration, the kubelet will attempt to open a socket to your container on the specified port. If it can establish a connection, the container is considered healthy, if it can't it is considered a failure.
But has far as I known, socket client is connected before the server perform accept on the socket. This TCP handshake is managed by the OS... So how Kubernetes "known" the state of the socket?
To give a little be of context I'm trying to write a unit test in my application (C++) and I cannot figure how K8s handle this, but in k8s it does work as expected (I mean that if I do not accept the connection it will declare my container as not alive).
Thank you for your time and consideration!
Edit 1
Sorry @Steffen Ullrich it take me some time but here a sample of code: https://github.com/quentingodeau/k8s-probe
And then the traces that I get:
$ kubectl logs -f $(kubectl get pods | egrep -o 'sample-deployment-[^ ]*')
[2021-07-10 18:46:22.837] [info] Server acccept the client...
[2021-07-10 18:46:23.838] [info] Server acccept the client...
[2021-07-10 18:46:24.840] [info] Server acccept the client...
[2021-07-10 18:46:25.837] [info] Server acccept the client...
[2021-07-10 18:46:26.836] [info] Server acccept the client...
[2021-07-10 18:46:27.839] [info] Server acccept the client...
[2021-07-10 18:46:28.840] [info] Server acccept the client...
[2021-07-10 18:46:29.836] [info] Server acccept the client...
[2021-07-10 18:46:30.843] [info] Server acccept the client...
[2021-07-10 18:46:31.028] [info] Send SIGUSR1
[2021-07-10 18:46:31.836] [info] Server acccept the client...
[2021-07-10 18:46:31.836] [info] Start to not procssing incoming connection
[2021-07-10 18:46:35.855] [info] End of application (signal=15)