Multi-Container Pod Design Patterns
Auteur: Fabrice JAMMES (LinkedIn). Date: Nov 24, 2025 · 10 min read
Quick Exercise: Fix the Bugs! 🐛
Objective
Create a pod with an init container and a sidecar - There are 2 bugs to fix!
Scenario
- Init container: generates an
index.htmlwith system info - Main container: nginx 1.25.3 web server
- Sidecar: counts requests in access logs every 10 seconds
Task
Deploy the following pod and fix the errors:
Questions
- Find the 2 bugs (hint: check volume names carefully!)
- What happens when you try to deploy this pod?
- How do you debug init container failures?
- Once fixed, how can you verify:
- The init container completed successfully?
- The nginx server is running?
- The sidecar is counting requests?
Debugging Commands
Expected Behavior (After Fix)
- Init container runs first and creates
/web/index.html - Nginx starts and serves the HTML file
- Sidecar continuously counts requests every 10 seconds
- All containers share volumes properly
Key Learning Points
- Volume names must match exactly between
volumeMountsandvolumesdefinitions - Init containers must complete before main containers start
- Multiple containers in a pod share the same volumes
- Use
kubectl describe podto identify volume mount errors - Init container failures prevent the pod from starting