Chọn volume theo lifecycle
- emptyDir: scratch/handoff trong cùng Pod; mất khi Pod recreate.
- ConfigMap/Secret volume: projection key → file, phù hợp config/credential injection; read-only và update/reload tùy process.
- hostPath: node-local, coupling và security risk cao; không mặc định là persistence.
- PV/PVC: storage lifecycle/recovery riêng, cần bài storage và policy.
Debug mount
Đối chiếu volume name ở Pod với volumeMount name/path/container, key và mode; dùng describe/events rồi exec kiểm tra file/permission. subPath có caveat update. Secret phải được redact khỏi logs/output và không commit plaintext.
Bài tập
Dựng emptyDir handoff, ConfigMap/Secret volume, tạo lỗi mount/key/permission/subPath, quan sát update/lifecycle và sửa. Lập matrix chọn volume cho scratch, config, credential và persistent data; cleanup an toàn.