Bird
Raised Fist0
Kubernetesdevops~20 mins

Exec probe configuration in Kubernetes - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Exec Probe Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the result of this exec probe configuration?
Given the following Kubernetes pod YAML snippet, what will be the status of the exec probe if the command exits with code 1?
Kubernetes
livenessProbe:
  exec:
    command:
    - /bin/sh
    - -c
    - exit 1
  initialDelaySeconds: 5
  periodSeconds: 10
AThe probe succeeds and the container continues running.
BThe probe fails and the container is restarted.
CThe probe is ignored because exit code 1 is treated as success.
DThe pod enters CrashLoopBackOff immediately.
Attempts:
2 left
💡 Hint
Exec probes consider exit code 0 as success; any other code means failure.
❓ Configuration
intermediate
2:00remaining
Identify the correct exec probe configuration to check a file exists
Which exec probe configuration correctly checks if the file /tmp/healthy exists inside the container?
A
exec:
  command:
  - test
  - -f
  - /tmp/healthy
B
exec:
  command:
  - ls
  - /tmp/healthy
C
exec:
  command:
  - echo
  - /tmp/healthy
D
exec:
  command:
  - cat
  - /tmp/healthy
Attempts:
2 left
💡 Hint
Use a command that returns exit code 0 if the file exists.
❓ Troubleshoot
advanced
2:00remaining
Why does this exec probe always fail?
A pod has this exec probe: livenessProbe: exec: command: - /bin/false initialDelaySeconds: 5 periodSeconds: 10 Why does the container keep restarting?
ABecause the exec probe command is missing arguments.
BBecause the initialDelaySeconds is too short for the container to start.
CBecause /bin/false always exits with code 1, causing probe failure.
DBecause the probe type should be HTTP, not exec.
Attempts:
2 left
💡 Hint
Check the exit code behavior of /bin/false.
🔀 Workflow
advanced
2:00remaining
Order the steps to add an exec readiness probe to a deployment
Put these steps in the correct order to add an exec readiness probe that checks if a service is ready:
A2,1,3,4
B3,1,2,4
C1,3,2,4
D1,2,3,4
Attempts:
2 left
💡 Hint
You must edit before applying, and verify last.
✅ Best Practice
expert
2:00remaining
Which exec probe command is best for checking a web server health inside a container?
You want an exec probe to check if a web server inside the container is healthy by verifying port 8080 is open. Which command is best?
A
exec:
  command:
  - nc
  - -z
  - localhost
  - "8080"
B
exec:
  command:
  - curl
  - -I
  - http://localhost:8080/health
C
exec:
  command:
  - telnet
  - localhost
  - 8080
D
exec:
  command:
  - ping
  - localhost
Attempts:
2 left
💡 Hint
Use a command that checks if a port is open without requiring HTTP response.

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

  1. Step 1: Understand exec probe functionality

    An exec probe runs a command inside the container to check its health status.
  2. Step 2: Compare with other options

    Options A, B, and D relate to scheduling, networking, and storage, not health checks.
  3. Final Answer:

    To run a command inside a container to check if it is healthy -> Option D
  4. 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

  1. Step 1: Check exec command format

    The command must be an array of strings, e.g., ['cat', '/tmp/healthy'].
  2. 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.
  3. Final Answer:

    Correct exec probe with command array and delays -> Option A
  4. 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:
livenessProbe:
  exec:
    command: ['test', '-f', '/tmp/healthy']
  initialDelaySeconds: 3
  periodSeconds: 5
What happens if the file /tmp/healthy does not exist inside the container?
medium
A. The probe ignores the missing file and logs a warning
B. The probe passes and container continues running
C. The probe fails and Kubernetes restarts the container after retries
D. The container is immediately deleted without restart

Solution

  1. Step 1: Understand exec probe command

    The command 'test -f /tmp/healthy' returns success if the file exists, failure if not.
  2. Step 2: Effect of probe failure

    If the probe fails repeatedly, Kubernetes restarts the container to recover.
  3. Final Answer:

    The probe fails and Kubernetes restarts the container after retries -> Option C
  4. Quick Check:

    Missing file = probe fails = restart [OK]
Hint: Missing file causes exec probe failure and container restart [OK]
Common Mistakes:
  • Assuming probe passes if file missing
  • Thinking container deletes without restart
  • Believing probe ignores errors silently
4. You configured an exec readiness probe but your pod never becomes ready. Which of these is the most likely cause?
medium
A. The exec command is missing the command array syntax and uses a single string
B. The initialDelaySeconds is set too high
C. The container image is missing
D. The pod has no resource limits defined

Solution

  1. Step 1: Check exec command syntax

    Exec probe commands must be an array of strings; a single string causes probe failure.
  2. Step 2: Understand probe failure effect

    If the probe fails, the pod is not marked ready, so it never becomes ready.
  3. Final Answer:

    Exec command missing array syntax causes probe failure -> Option A
  4. Quick Check:

    Exec command array syntax missing = probe fails [OK]
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?
hard
A. livenessProbe:\n exec:\n command: '/bin/check.sh'\n initialDelaySeconds: 10\n periodSeconds: 5\n failureThreshold: 3
B. livenessProbe:\n exec:\n command: ['/bin/check.sh']\n initialDelaySeconds: 10\n periodSeconds: 5\n failureThreshold: 3
C. livenessProbe:\n exec:\n command: ['/bin/check.sh']\n initialDelaySeconds: 5\n periodSeconds: 10\n failureThreshold: 3
D. livenessProbe:\n exec:\n command: ['/bin/check.sh']\n initialDelaySeconds: 10\n periodSeconds: 5\n failureThreshold: 1

Solution

  1. Step 1: Verify command syntax and initial delay

    Command must be an array; initialDelaySeconds must be 10 as required.
  2. Step 2: Check periodSeconds and failureThreshold

    PeriodSeconds should be 5 for retry every 5 seconds; failureThreshold 3 means fail after 3 tries.
  3. Final Answer:

    Correct YAML with command array, initialDelaySeconds 10, periodSeconds 5, failureThreshold 3 -> Option B
  4. Quick Check:

    Command array + delays + failureThreshold correct = livenessProbe:\n exec:\n command: ['/bin/check.sh']\n initialDelaySeconds: 10\n periodSeconds: 5\n failureThreshold: 3 [OK]
Hint: Use array for command and set delays and failureThreshold as numbers [OK]
Common Mistakes:
  • Using string instead of array for command
  • Swapping periodSeconds and initialDelaySeconds values
  • Setting failureThreshold too low or missing
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard