A TCP socket probe checks whether Kubernetes can establish a TCP connection to a specified port on a container. A successful connection means the probe succeeds; failure to connect within the allowed time means failure. section 6.2.2 section 6.2.5
Use this probe for applications that accept TCP connections but do not expose an HTTP health-check endpoint. Unlike an exec probe, it does not run a command inside the container. section 6.2.5
livenessProbe:
tcpSocket: #1
port: 1234 #1
periodSeconds: 2 #2
failureThreshold: 1 #3
This configuration checks port 1234 every two seconds. One failed attempt is enough to mark the container unhealthy. section 6.2.5
The same TCP connection test can serve different lifecycle purposes:
- As a liveness probe, failure marks the container unhealthy; Kubernetes terminates it and may restart it according to the restart policy. section 6.2.2
- As a readiness probe, successful connection marks the container ready, while failure removes its pod from matching Services. section 11.6.1
- Readiness timing can use initialDelaySeconds, periodSeconds, failureThreshold, timeoutSeconds, and successThreshold; successThreshold applies specifically to readiness. section 11.6.1
