📖 Scenario: You are deploying a web application in Kubernetes. Sometimes the app takes time to start before it can respond to health checks. To avoid Kubernetes killing the pod too early, you will use a startupProbe.
🎯 Goal: You will create a Kubernetes pod manifest with a startupProbe that checks the app's readiness by sending an HTTP GET request to /healthz on port 8080. You will configure the probe to wait longer before failing, allowing the app to start properly.
📋 What You'll Learn
Create a pod manifest named web-app with a container named web-container running image nginx.
Add a startupProbe that sends an HTTP GET request to /healthz on port 8080.
Set failureThreshold to 10 and periodSeconds to 5 in the startupProbe.
Print the final pod manifest YAML.
💡 Why This Matters
🌍 Real World
Startup probes are used in Kubernetes to handle applications that take time to start. This prevents Kubernetes from killing pods too early during startup.
💼 Career
Understanding startup probes is important for DevOps roles managing Kubernetes clusters to ensure application stability and proper health monitoring.
Progress0 / 4 steps
1
Create the basic pod manifest
Create a Kubernetes pod manifest with apiVersion set to v1, kind set to Pod, and metadata.name set to web-app. Add a single container named web-container using the image nginx.
Kubernetes
Hint
Start with the basic pod structure and add one container with the specified name and image.
2
Add the startupProbe configuration
Add a startupProbe section under the container web-container. Configure it to send an HTTP GET request to path /healthz on port 8080.
Kubernetes
Hint
Use startupProbe with httpGet specifying the path and port.
3
Configure failureThreshold and periodSeconds
Inside the startupProbe, add failureThreshold set to 10 and periodSeconds set to 5 to control how long Kubernetes waits before marking the pod as failed.
Kubernetes
Hint
These settings tell Kubernetes to try the probe 10 times every 5 seconds before failing.
4
Print the final pod manifest
Print the complete pod manifest YAML with the startupProbe configured as specified.
Kubernetes
Hint
Make sure the entire YAML is printed exactly as configured.
Practice
(1/5)
1. What is the main purpose of a startupProbe in Kubernetes?
easy
A. To monitor CPU and memory usage of the pod
B. To restart the pod immediately when it crashes
C. To check if the application has started before other health checks run
D. To manage network traffic routing to the pod
Solution
Step 1: Understand the role of startupProbe
The startupProbe is designed to check if an application has started successfully before Kubernetes runs readiness or liveness probes.
Step 2: Differentiate from other probes
Unlike liveness or readiness probes, startupProbe prevents Kubernetes from killing pods that take longer to start.
Final Answer:
To check if the application has started before other health checks run -> Option C
Quick Check:
startupProbe checks app start status = A [OK]
Hint: Startup probe delays other checks until app starts [OK]
Common Mistakes:
Confusing startupProbe with livenessProbe
Thinking startupProbe manages resource usage
Assuming startupProbe handles traffic routing
2. Which of the following is the correct syntax to define a startupProbe using an HTTP GET request in a pod spec?
easy
A. startupProbe:
exec:
command: ["curl", "-f", "http://localhost:8080/healthz"]
timeoutSeconds: 5
C. startupProbe:
tcpSocket:
port: 8080
initialDelaySeconds: 5
D. startupProbe:
httpGet:
path: /status
port: 80
successThreshold: 3
Solution
Step 1: Identify correct HTTP GET syntax for startupProbe
The startupProbe uses httpGet with path and port fields, plus timing settings like failureThreshold and periodSeconds.
Step 2: Compare options for correctness
startupProbe:
httpGet:
path: /healthz
port: 8080
failureThreshold: 30
periodSeconds: 10 correctly uses httpGet with path /healthz, port 8080, and timing fields. Other options use exec or tcpSocket or wrong ports/fields.
Hint: Longer failureThreshold and periodSeconds prevent early restarts [OK]
Common Mistakes:
Removing startupProbe loses slow start protection
Confusing startupProbe with readinessProbe
Setting initialDelaySeconds on livenessProbe doesn't fix startup timing
5. You have a slow-starting app that takes about 3 minutes to initialize. How should you configure the startupProbe to avoid premature pod restarts?
hard
A. Set failureThreshold to 18 and periodSeconds to 10
B. Set failureThreshold to 3 and periodSeconds to 30
C. Set failureThreshold to 1 and periodSeconds to 100
D. Disable startupProbe and rely on livenessProbe with initialDelaySeconds 180
Solution
Step 1: Calculate total startupProbe timeout needed
App needs 3 minutes (180 seconds) to start. Total timeout = failureThreshold x periodSeconds.
Step 2: Choose values matching 180 seconds
Set failureThreshold to 18 and periodSeconds to 10: 18 x 10 = 180 seconds, allowing full startup time before restart.
Step 3: Evaluate other options
Set failureThreshold to 1 and periodSeconds to 100: failureThreshold to 1 and periodSeconds to 100 = 100 seconds (too short). Set failureThreshold to 3 and periodSeconds to 30: 3 x 30 = 90 seconds (too short). Disable startupProbe and rely on livenessProbe with initialDelaySeconds 180 disables startupProbe, risking premature restarts from livenessProbe.
Final Answer:
Set failureThreshold to 18 and periodSeconds to 10 -> Option A
Quick Check:
failureThreshold x periodSeconds = startup timeout [OK]
Hint: Multiply failureThreshold by periodSeconds to match startup time [OK]
Common Mistakes:
Configuring insufficient total timeout (failureThreshold x periodSeconds < 180s)
Disabling startupProbe causing premature restarts
Setting only initialDelaySeconds without startupProbe
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.