SecurityContext nên cấu hình gì cho Pod/container?

SecurityContext cấu hình quyền chạy container như user/group, privileged mode, capabilities, read-only root filesystem và privilege escalation. Mục tiêu là giảm quyền runtime nếu container bị khai thác.

Ví dụ:

yaml
securityContext:
  runAsNonRoot: true
  allowPrivilegeEscalation: false
  readOnlyRootFilesystem: true
  capabilities:
    drop: ["ALL"]

Cần test app vì read-only filesystem hoặc non-root có thể yêu cầu chỉnh path ghi tạm, permissions hoặc image build.

Xem toàn bộ Docker & Kubernetes cùng filter theo level & chủ đề con.

Mở danh sách Docker & Kubernetes