궁금한게 많은 개발자 노트

[ K8S ] CKS - PSA (Pod Security Admission) 본문

DevOps/CKS

[ K8S ] CKS - PSA (Pod Security Admission)

궁금한게 많은 개발자 2026. 3. 25. 21:13
Configure the namespace restricted-ns to enforce the restricted Pod Security Standard. Also, configure it to trigger a warn and audit log if pods violating the baseline standard are created.

 

[ 포함된 개념 ]

  • 과거 PSP(Pod Security Policy)가 폐지되고 도입된 네임스페이스 라벨 기반 파드 보안 제어 기능
    • Privileged, Baseline, Restricted 3단계
      • privileged > 제한 없음 없음
      • baseline > 최소한의 제한 privileged 모드, hostNetwork, hostPID 등 차단
      • restricted > 가장 엄격 baseline + runAsNonRoot, readOnlyRootFilesystem 등 필수
  • PSA 모드
    • enforce > 위반 시 Pod 생성 거부
    • warn > 위반 시 경고 메시지 출력 (생성은 허용)
    • audit > 위반 시 audit 로그 기록 (생성은 허용)
# The per-mode level label indicates which policy level to apply for the mode.
#
# MODE must be one of `enforce`, `audit`, or `warn`.
# LEVEL must be one of `privileged`, `baseline`, or `restricted`.
pod-security.kubernetes.io/<MODE>: <LEVEL>

# Optional: per-mode version label that can be used to pin the policy to the
# version that shipped with a given Kubernetes minor version (for example v1.35).
#
# MODE must be one of `enforce`, `audit`, or `warn`.
# VERSION must be a valid Kubernetes minor version, or `latest`.
pod-security.kubernetes.io/<MODE>-version: <VERSION>

[ 풀이 방법 ]

# 1. Restricted 레벨 강제 (위반 파드 생성 차단)
kubectl label namespace restricted-ns pod-security.kubernetes.io/enforce=restricted

# 2. Baseline 레벨 위반 시 경고 출력
kubectl label namespace restricted-ns pod-security.kubernetes.io/warn=baseline

# 3. Baseline 레벨 위반 시 감사 로그 기록
kubectl label namespace restricted-ns pod-security.kubernetes.io/audit=baseline
Comments