If the exec probe command returns a non-zero exit code, Kubernetes considers the container unhealthy and may restart it depending on the probe type.
Click to reveal answer
intermediate
Why use exec probes instead of HTTP or TCP probes?
Exec probes allow custom health checks by running any command inside the container, useful when HTTP or TCP checks are not applicable.
Click to reveal answer
What does an exec probe do in Kubernetes?
ARuns a command inside the container to check health
BSends an HTTP request to the container
CChecks if a TCP port is open
DMonitors container CPU usage
✗ Incorrect
Exec probes run a command inside the container to determine health.
Where do you specify the exec command in a Kubernetes probe?
AUnder env: variables: in container spec
BUnder httpGet: path: in livenessProbe
CUnder exec: command: in livenessProbe or readinessProbe
DUnder tcpSocket: port: in readinessProbe
✗ Incorrect
The exec command is specified under exec: command: in the probe section.
What exit code from an exec probe command means the container is healthy?
A1
B0
CAny non-zero code
D255
✗ Incorrect
Exit code 0 means success and healthy container.
If an exec probe fails repeatedly, what does Kubernetes do?
ARestarts the container
BIgnores the failure
CDeletes the Pod immediately
DScales the deployment up
✗ Incorrect
Kubernetes restarts the container if the liveness exec probe fails repeatedly.
Which probe type is best when you need to run a custom script inside the container?
ATCP probe
BHTTP probe
CNone of the above
DExec probe
✗ Incorrect
Exec probes allow running custom scripts or commands inside the container.
Explain how to configure an exec probe in a Kubernetes Pod YAML file.
Think about where the exec command goes and timing settings.
You got /3 concepts.
Describe what happens when an exec probe command fails in Kubernetes.
Focus on exit codes and Kubernetes reaction.
You got /3 concepts.
Practice
(1/5)
1. What is the main purpose of an exec probe in Kubernetes?
easy
A. To schedule pods on specific nodes
B. To expose container ports to the outside world
C. To create persistent storage volumes
D. To run a command inside a container to check if it is healthy
Solution
Step 1: Understand exec probe functionality
An exec probe runs a command inside the container to check its health status.
Step 2: Compare with other options
Options A, B, and D relate to scheduling, networking, and storage, not health checks.
Final Answer:
To run a command inside a container to check if it is healthy -> Option D
Quick Check:
Exec probe = runs command inside container [OK]
Hint: Exec probe runs commands inside container to check health [OK]
Common Mistakes:
Confusing exec probe with port exposure
Thinking exec probe schedules pods
Mixing exec probe with storage management
2. Which of the following is the correct syntax snippet to define an exec liveness probe in a pod spec?
easy
A. livenessProbe:\n exec:\n command: ['cat', '/tmp/healthy']\n initialDelaySeconds: 5\n periodSeconds: 10
B. livenessProbe:\n httpGet:\n path: /healthz\n port: 8080\n initialDelaySeconds: 5
C. livenessProbe:\n exec:\n command: 'cat /tmp/healthy'\n initialDelaySeconds: 5
D. livenessProbe:\n exec:\n command: cat /tmp/healthy\n initialDelaySeconds: 5
Solution
Step 1: Check exec command format
The command must be an array of strings, e.g., ['cat', '/tmp/healthy'].
Step 2: Validate YAML structure
livenessProbe:\n exec:\n command: ['cat', '/tmp/healthy']\n initialDelaySeconds: 5\n periodSeconds: 10 correctly uses the array syntax and includes initialDelaySeconds and periodSeconds.
Final Answer:
Correct exec probe with command array and delays -> Option A
Quick Check:
Exec command = array of strings [OK]
Hint: Exec command must be a list of strings in YAML [OK]
Common Mistakes:
Using a single string instead of array for command
Confusing exec probe with httpGet probe
Omitting required indentation or keys
3. Given this exec probe configuration in a pod spec:
Hint: Exec command must be array; single string causes failure [OK]
Common Mistakes:
Ignoring command array syntax errors
Blaming initialDelaySeconds without checking command
Confusing readiness with resource limits
5. You want to configure an exec liveness probe that waits 10 seconds before starting, runs the command ['/bin/check.sh'], retries every 5 seconds, and fails after 3 unsuccessful attempts. Which is the correct YAML snippet?