Example Documentation: Init Container Migration
Goal
Understand how an application starts only after a successful init container.
What Is Done
An init container writes a simple migration file into a shared emptyDir. The NGINX container then serves that file as content.
Typical Commands
kubectl apply -f manifests/
kubectl rollout status deployment/migration-app -n init-lab
kubectl logs -n init-lab deployment/migration-app -c migrate
kubectl exec -n init-lab deploy/migration-app -- cat /usr/share/nginx/html/index.html
Validate Success
- The init container completes successfully.
- Application Pods become ready only afterwards.
- The generated file is visible in the application container.
Common Mistakes
- The init container writes to a different volume than the app reads.
- Migrations are not idempotent.
- Init failures are only noticed as
Init:CrashLoopBackOff.