← Về danh sách bài học Bài 22/25

🔐 Bài 22: Pod Security

⏱️ Thời gian: 20 phút | 📚 Độ khó: Nâng cao

🎯 Sau bài học này, bạn sẽ:

1. SecurityContext

apiVersion: v1
kind: Pod
metadata:
  name: secure-pod
spec:
  securityContext:            # Pod-level
    runAsUser: 1000
    runAsGroup: 3000
    fsGroup: 2000
  containers:
    - name: app
      image: myapp:1.0
      securityContext:        # Container-level
        runAsNonRoot: true
        readOnlyRootFilesystem: true
        allowPrivilegeEscalation: false
        capabilities:
          drop:
            - ALL
          add:
            - NET_BIND_SERVICE

2. Best Practices

🔒 Security Checklist:
runAsNonRoot: true
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
capabilities.drop: ALL

3. Pod Security Standards

Level Mô tả
Privileged Không hạn chế (system pods)
Baseline Hạn chế cơ bản, dễ adopt
Restricted Nghiêm ngặt nhất
# Áp dụng Pod Security cho namespace
kubectl label namespace production \
    pod-security.kubernetes.io/enforce=restricted \
    pod-security.kubernetes.io/warn=restricted

📝 Tóm Tắt