A liveness probe is a check Kubernetes uses to see if a container is still running and healthy. If the probe fails, Kubernetes restarts the container to fix it.
Click to reveal answer
beginner
How does Kubernetes react when a liveness probe fails?
Kubernetes restarts the container to try to fix the problem when the liveness probe fails.
Click to reveal answer
intermediate
Name three types of liveness probes supported by Kubernetes.
Kubernetes supports HTTP GET requests, TCP socket checks, and running a command inside the container as liveness probes.
Click to reveal answer
intermediate
Why is it important to set the initial delay for a liveness probe?
Initial delay lets the container start up fully before Kubernetes starts checking its health, preventing false restarts.
Click to reveal answer
intermediate
What is the difference between a liveness probe and a readiness probe?
A liveness probe checks if the container should be restarted, while a readiness probe checks if the container is ready to accept traffic.
Click to reveal answer
What happens if a liveness probe fails in Kubernetes?
AThe pod is scaled up
BThe container is restarted
CNothing happens
DThe container is deleted permanently
✗ Incorrect
When a liveness probe fails, Kubernetes restarts the container to recover it.
Which of these is NOT a type of liveness probe?
AMemory usage check
BTCP socket check
CHTTP GET request
DRunning a command
✗ Incorrect
Memory usage check is not a built-in liveness probe type in Kubernetes.
Why do we use an initial delay in liveness probes?
ATo disable the probe
BTo delay container startup
CTo speed up restarts
DTo wait before starting health checks
✗ Incorrect
Initial delay waits before starting health checks to avoid false failures during startup.
Which Kubernetes object uses liveness probes?
AService
BConfigMap
CPod
DNamespace
✗ Incorrect
Liveness probes are configured on containers inside Pods.
What is the main goal of a liveness probe?
ATo check if the container is alive and restart if not
BTo check if the container is ready to serve traffic
CTo monitor network traffic
DTo update container images
✗ Incorrect
Liveness probes check if the container is alive and restart it if it is not.
Explain what a liveness probe is and why it is useful in Kubernetes.
Think about how Kubernetes keeps containers running smoothly.
You got /3 concepts.
Describe the different types of liveness probes and when you might use each.
Consider how you can check container health in different ways.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of a liveness probe in Kubernetes?
easy
A. To check if a container is alive and restart it if it is not
B. To check if a container is ready to accept traffic
C. To monitor the CPU usage of a container
D. To scale the number of pods automatically
Solution
Step 1: Understand the role of liveness probes
Liveness probes check if a container is still running properly. If not, Kubernetes restarts it to fix issues.
Step 2: Differentiate from readiness probes
Readiness probes check if a container can receive traffic, but liveness probes focus on container health and restarting.
Final Answer:
To check if a container is alive and restart it if it is not -> Option A
Quick Check:
Liveness probe = container health check and restart [OK]
But your container keeps restarting even though the app is healthy. What is the most likely cause?
medium
A. The port number 80 is invalid
B. The initialDelaySeconds is too high
C. The probe path /health is incorrect or not responding
D. The failureThreshold is set too high
Solution
Step 1: Analyze probe failure reasons
If the probe path is wrong or the app does not respond at /health, the probe fails and restarts the container.
Step 2: Check other parameters
Initial delay of 10 seconds is usually enough. Failure threshold of 3 means 3 failures before restart, which is normal. Port 80 is valid.
Final Answer:
The probe path /health is incorrect or not responding -> Option C
Quick Check:
Wrong probe path causes restarts [OK]
Hint: Check probe URL path correctness first [OK]
Common Mistakes:
Changing initialDelaySeconds unnecessarily
Misunderstanding failureThreshold effect
Assuming port 80 is invalid
5. You want to create a liveness probe that checks a TCP port 3306 on your container every 10 seconds, but only start checking after 30 seconds from container start. Which is the correct configuration snippet?
hard
A. "livenessProbe:\n tcpSocket:\n port: '3306'\n initialDelaySeconds: 10\n periodSeconds: 30"
D. "livenessProbe:\n tcpSocket:\n port: 3306\n initialDelaySeconds: 30\n periodSeconds: 10"
Solution
Step 1: Identify TCP socket probe syntax
The tcpSocket probe uses port as a number, with initialDelaySeconds and periodSeconds set as required. "livenessProbe:\n tcpSocket:\n port: 3306\n initialDelaySeconds: 30\n periodSeconds: 10" matches this.
Step 2: Check timing and port correctness
"livenessProbe:\n tcpSocket:\n port: 3306\n initialDelaySeconds: 30\n periodSeconds: 10" sets initial delay to 30 seconds and period to 10 seconds, matching the requirement. Other options have wrong timing or use HTTP or exec probes incorrectly.