0
0
Kubernetesdevops~10 mins

TCP probe configuration in Kubernetes - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - TCP probe configuration
Pod starts
Kubelet sets TCP probe
Kubelet tries TCP connection to pod's port
Pod Ready
Repeat probe at intervals
The kubelet repeatedly tries to open a TCP connection to the pod's port. If successful, the pod is marked ready; if not, it is marked not ready.
Execution Sample
Kubernetes
readinessProbe:
  tcpSocket:
    port: 8080
  initialDelaySeconds: 5
  periodSeconds: 10
This config sets a TCP readiness probe on port 8080, starting 5 seconds after pod start, checking every 10 seconds.
Process Table
StepActionTCP Connection AttemptResultPod Status
1Wait initialDelaySeconds (5s)No attemptN/AUnknown
2Attempt TCP connection to port 8080Connect to 8080SuccessReady
3Wait periodSeconds (10s)No attemptN/AReady
4Attempt TCP connection to port 8080Connect to 8080SuccessReady
5Wait periodSeconds (10s)No attemptN/AReady
6Attempt TCP connection to port 8080Connect to 8080FailureNot Ready
7Wait periodSeconds (10s)No attemptN/ANot Ready
8Attempt TCP connection to port 8080Connect to 8080SuccessReady
💡 Probe continues indefinitely; pod status updates based on TCP connection success or failure.
Status Tracker
VariableStartAfter Step 2After Step 4After Step 6After Step 8
Pod StatusUnknownReadyReadyNot ReadyReady
TCP Connection ResultN/ASuccessSuccessFailureSuccess
Key Moments - 2 Insights
Why does the pod status change to Not Ready at step 6 even though the pod is running?
Because the TCP probe at step 6 failed to connect to port 8080, indicating the pod is not responding on that port, so kubelet marks it Not Ready (see execution_table row 6).
What happens during initialDelaySeconds before the first probe?
No TCP connection attempts are made during initialDelaySeconds (step 1), so pod status remains Unknown until the first probe (execution_table row 1).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the Pod Status after the first successful TCP connection?
AUnknown
BNot Ready
CReady
DTerminated
💡 Hint
Check execution_table row 2 under Pod Status.
At which step does the TCP connection fail?
AStep 4
BStep 6
CStep 8
DStep 2
💡 Hint
Look at execution_table row 6 under TCP Connection Attempt and Result.
If initialDelaySeconds was set to 0, what would change in the execution table?
AStep 1 would attempt TCP connection immediately
BPod Status would start as Ready
CTCP connection attempts would stop
DPod would never become Not Ready
💡 Hint
Refer to execution_table row 1 where no attempt is made due to initialDelaySeconds.
Concept Snapshot
TCP Probe Configuration in Kubernetes:
- Uses tcpSocket to check pod port availability
- initialDelaySeconds delays first check
- periodSeconds sets interval between checks
- Success means pod is Ready; failure means Not Ready
- Probe runs repeatedly to monitor pod health
Full Transcript
In Kubernetes, a TCP probe checks if a pod is ready by trying to open a TCP connection to a specified port. The kubelet waits for an initial delay, then attempts the connection repeatedly at set intervals. If the connection succeeds, the pod is marked Ready; if it fails, the pod is marked Not Ready. This helps Kubernetes know if the pod is healthy and can receive traffic. The example shows a probe on port 8080 with a 5-second initial delay and 10-second intervals. The execution table traces connection attempts and pod status changes over time.