A TCP probe checks if a container is accepting TCP connections on a specified port. It helps Kubernetes know if the container is healthy by trying to open a TCP connection.
Click to reveal answer
beginner
Which Kubernetes probe type uses a TCP socket to check container health?
The TCP Socket probe type uses a TCP connection to check if the container is ready or alive.
Click to reveal answer
intermediate
What fields are required to configure a TCP probe in a Kubernetes pod spec?
You need to specify tcpSocket with a port number. Optionally, you can set initialDelaySeconds, periodSeconds, and timeoutSeconds.
Click to reveal answer
intermediate
How does Kubernetes react if a TCP probe fails?
If the TCP probe fails, Kubernetes considers the container unhealthy. For liveness probes, it may restart the container. For readiness probes, it stops sending traffic to the container.
Click to reveal answer
beginner
Example snippet: How to define a TCP readiness probe on port 8080 in a pod spec?
AIf the container accepts TCP connections on a port
BIf the container returns HTTP status 200
CIf the container's CPU usage is low
DIf the container's disk space is sufficient
✗ Incorrect
A TCP probe tries to open a TCP connection to check container health.
Which field specifies the port number in a TCP probe configuration?
Aport
Bpath
Ccommand
Dhost
✗ Incorrect
The 'port' field inside 'tcpSocket' defines the port to check.
What happens if a liveness TCP probe fails repeatedly?
AKubernetes ignores the failure
BKubernetes deletes the pod permanently
CKubernetes restarts the container
DKubernetes scales the pod up
✗ Incorrect
Failing liveness probes cause Kubernetes to restart the container.
Which probe type can use a TCP socket check?
ANone of the above
BLiveness and Readiness probes
COnly Readiness probes
DOnly Liveness probes
✗ Incorrect
Both liveness and readiness probes can use TCP socket checks.
What is the purpose of 'initialDelaySeconds' in a TCP probe?
ANumber of retries before failure
BTimeout for each probe attempt
CInterval between probes
DWait time before starting probes after container start
✗ Incorrect
'initialDelaySeconds' sets how long to wait before the first probe.
Explain how to configure a TCP readiness probe in a Kubernetes pod and why it is useful.
Think about how Kubernetes decides if a container is ready to receive requests.
You got /4 concepts.
Describe what happens when a TCP liveness probe fails and how Kubernetes responds.
Consider how Kubernetes keeps containers healthy automatically.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of a TCP probe in Kubernetes?
easy
A. To check the container's memory usage
B. To monitor CPU usage of a container
C. To verify the container's file system integrity
D. To check if a container accepts TCP connections on a specified port
Solution
Step 1: Understand TCP probe function
A TCP probe tests if a container is accepting TCP connections on a specific port.
Step 2: Compare with other options
CPU, memory, and file system checks are not done by TCP probes but by other mechanisms.
Final Answer:
To check if a container accepts TCP connections on a specified port -> Option D
Quick Check:
TCP probe = connection check [OK]
Hint: TCP probe checks port connectivity, not resource usage [OK]
Common Mistakes:
Confusing TCP probe with CPU or memory monitoring
Thinking TCP probe checks file system health
Assuming TCP probe checks HTTP endpoints
2. Which of the following is the correct syntax to define a TCP liveness probe in a pod spec?
easy
A. livenessProbe:
tcpSocket:
path: "/health"
initialDelaySeconds: 5
periodSeconds: 10
B. livenessProbe:
httpGet:
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
C. livenessProbe:
tcpSocket:
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
D. livenessProbe:
exec:
command: ["curl", "localhost:8080"]
initialDelaySeconds: 5
periodSeconds: 10
Solution
Step 1: Identify TCP probe syntax
TCP probes use tcpSocket with a port field, no path.
Step 2: Check options for correctness
livenessProbe:
tcpSocket:
port: 8080
initialDelaySeconds: 5
periodSeconds: 10 uses tcpSocket with port 8080 and timing fields correctly. Others use HTTP or exec or invalid fields.
Final Answer:
livenessProbe with tcpSocket and port field -> Option C
Quick Check:
TCP probe syntax = tcpSocket + port [OK]
Hint: TCP probes use tcpSocket with port, no path [OK]
Common Mistakes:
Using httpGet or exec instead of tcpSocket for TCP probes
Adding a path field to tcpSocket (invalid)
Omitting port number in tcpSocket
3. Given this pod spec snippet, what will happen if the container does not accept TCP connections on port 3306?
4. You configured a TCP readiness probe but Kubernetes reports probe failures immediately after pod start. Which is the most likely cause?
medium
A. initialDelaySeconds is missing or too low, so probe runs before container is ready
B. tcpSocket port is set to 0, which is invalid
C. periodSeconds is set too high, causing delayed checks
D. readinessProbe cannot use tcpSocket, only httpGet
Solution
Step 1: Analyze probe timing parameters
Without initialDelaySeconds, probe starts immediately, possibly before container is ready.
Step 2: Evaluate other options
Port 0 is invalid but would cause different errors; periodSeconds affects frequency, not immediate failure; tcpSocket is valid for readiness probes.
Final Answer:
initialDelaySeconds is missing or too low, so probe runs before container is ready -> Option A
Quick Check:
Missing initialDelaySeconds = early probe failure [OK]
Hint: Set initialDelaySeconds to delay probe start [OK]
Common Mistakes:
Assuming tcpSocket is invalid for readiness probes
Ignoring initialDelaySeconds importance
Confusing periodSeconds with initialDelaySeconds
5. You want to configure a TCP readiness probe for a database container on port 5432. The container takes about 20 seconds to start accepting connections. Which configuration is best to avoid false failures?