Example Documentation: Sidecar Pattern
Goal
Trace the sidecar pattern with a main container and a supporting log container.
What Is Done
The app container regularly writes to a log file. The sidecar reads the same file from a shared volume and emits it to stdout.
Typical Commands
kubectl apply -f manifests/
kubectl get pods -n sidecar-lab
kubectl logs -n sidecar-lab deploy/sidecar-demo -c log-shipper --tail=20
Validate Success
- Both containers run in the same Pod.
- The sidecar shows events from the main container.
- The shared volume is mounted in both containers.
Common Mistakes
- Sidecar and app use different mount paths.
- Sidecar resources are forgotten.
- The sidecar exits and repeatedly restarts the Pod.