What if your app could tell you when it's sick and fix itself without you lifting a finger?
Why HTTP probe configuration in Kubernetes? - Purpose & Use Cases
Imagine you have a website running on a server, and you want to check if it is working properly. You try to do this by manually opening the website in a browser or running commands to see if it responds.
Manually checking the website is slow and tiring. You might forget to check regularly, or miss problems that happen when you are not looking. This can cause your users to face errors without you knowing.
HTTP probe configuration in Kubernetes automatically checks if your application is healthy by sending simple web requests. If the app does not respond correctly, Kubernetes can restart it or take other actions to keep your service running smoothly.
curl http://myapp:8080/health # Check manually every time
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 5
periodSeconds: 10This lets your system detect and fix problems automatically, keeping your app reliable without you watching all the time.
A company runs an online store. With HTTP probes, if the store's web server stops responding, Kubernetes restarts it quickly, so customers don't see errors or broken pages.
Manual health checks are slow and easy to miss.
HTTP probes automate checking app health with simple web requests.
This helps keep apps running smoothly and users happy.
Practice
Solution
Step 1: Understand the role of HTTP probes
HTTP probes send HTTP requests to the app to check if it is alive and ready.Step 2: Identify the correct purpose
Only To check if the application is running and responding to HTTP requests describes checking app health via HTTP requests.Final Answer:
To check if the application is running and responding to HTTP requests -> Option CQuick Check:
HTTP probe purpose = health check [OK]
- Confusing probes with deployment or logging
- Thinking probes manage network traffic
- Assuming probes store logs
Solution
Step 1: Review HTTP probe syntax
The correct HTTP probe useshttpGetwithpathandportkeys.Step 2: Identify the correct YAML structure
livenessProbe: httpGet: path: /healthz port: 8080 initialDelaySeconds: 5 periodSeconds: 10 correctly useshttpGetwithpathandport. livenessProbe: httpGet: url: http://localhost:8080/healthz initialDelaySeconds: 5 periodSeconds: 10 is invalid becauseurlis not a valid key.Final Answer:
Correct HTTP liveness probe syntax with httpGet, path, and port -> Option BQuick Check:
httpGet uses path and port keys [OK]
- Using 'url' instead of 'path' in httpGet
- Confusing exec or tcpSocket probes with httpGet
- Wrong indentation or missing keys
livenessProbe:
httpGet:
path: /status
port: 8080
initialDelaySeconds: 10
periodSeconds: 5
What will Kubernetes do after the pod starts?Solution
Step 1: Understand initialDelaySeconds
This value tells Kubernetes to wait 10 seconds after pod start before first probe.Step 2: Understand periodSeconds
This value sets the interval between probes, here every 5 seconds.Final Answer:
Wait 10 seconds, then send an HTTP GET to /status every 5 seconds -> Option DQuick Check:
initialDelaySeconds = wait, periodSeconds = repeat interval [OK]
- Confusing initialDelaySeconds with periodSeconds
- Assuming immediate probe on pod start
- Mixing up timing values
readinessProbe:
httpGet:
path: /ready
port: 80
initialDelaySeconds: 5
periodSeconds: 10
timeoutSeconds: 2
But Kubernetes marks the pod as not ready even though the app is healthy. What is the likely problem?Solution
Step 1: Check probe path correctness
If the app does not respond correctly to /ready, probe fails and pod is not ready.Step 2: Evaluate timing parameters
initialDelaySeconds of 5 is reasonable; timeoutSeconds of 2 is short but typical; periodSeconds of 10 is normal.Final Answer:
The probe path /ready is incorrect or not handled by the app -> Option AQuick Check:
Probe path must match app endpoint [OK]
- Ignoring probe path correctness
- Changing timing values unnecessarily
- Assuming timeoutSeconds causes readiness failure
Solution
Step 1: Match initialDelaySeconds to 15 seconds
The probe must wait 15 seconds before first check, so initialDelaySeconds: 15.Step 2: Set periodSeconds to 3 seconds and timeoutSeconds to 1 second
Checks happen every 3 seconds, and timeout is 1 second as required.Final Answer:
Correct probe with initialDelaySeconds 15, periodSeconds 3, timeoutSeconds 1 -> Option AQuick Check:
initialDelay=15, period=3, timeout=1 matches requirements [OK]
- Swapping initialDelaySeconds and periodSeconds
- Setting timeoutSeconds longer than periodSeconds
- Using wrong path or port
Ready to prove it?
Pass the test and this pattern moves unknown
